Skip to content

Commit

Permalink
Make tag and branch listing more robust for Gitea.
Browse files Browse the repository at this point in the history
Sometimes the commit/statuses endpoint results in an empty response. But since the required information is already in the branch/tag response, we can just read it from there instead.
  • Loading branch information
s-ludwig committed Sep 24, 2023
1 parent 916fa6e commit 7727749
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions source/dubregistry/repositories/gitea.d
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class GiteaRepository : Repository {
foreach_reverse (tag; tags) {
try {
auto tagname = tag["name"].get!string;
Json commit = readJsonFromRepo("/commits/"~tag["commit"]["sha"].get!string~"/status", true, true);
ret ~= RefInfo(tagname, tag["commit"]["sha"].get!string, SysTime.fromISOExtString(commit["statuses"][0]["created_at"].get!string));
ret ~= RefInfo(tagname, tag["commit"]["sha"].get!string, SysTime.fromISOExtString(tag["commit"]["created"].get!string));
logDebug("Found tag for %s/%s: %s", m_owner, m_project, tagname);
} catch( Exception e ){
throw new Exception("Failed to process tag "~tag["name"].get!string~": "~e.msg);
Expand All @@ -134,8 +133,7 @@ class GiteaRepository : Repository {
RefInfo[] ret;
foreach_reverse( branch; branches ){
auto branchname = branch["name"].get!string;
Json commit = readJsonFromRepo("/commits/"~branch["commit"]["id"].get!string~"/status", true, true);
ret ~= RefInfo(branchname, branch["commit"]["id"].get!string, SysTime.fromISOExtString(commit["statuses"][0]["created_at"].get!string));
ret ~= RefInfo(branchname, branch["commit"]["id"].get!string, SysTime.fromISOExtString(branch["commit"]["timestamp"].get!string));
logDebug("Found branch for %s/%s: %s", m_owner, m_project, branchname);
}
return ret;
Expand Down

0 comments on commit 7727749

Please sign in to comment.