Skip to content

Commit

Permalink
Change how git ref id is obtained
Browse files Browse the repository at this point in the history
use the local ref database instead of calling ls-remote
  • Loading branch information
marko-bekhta committed Jun 26, 2024
1 parent 5ea2d2e commit 8eeff0b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.submodule.SubmoduleStatus;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -141,12 +140,12 @@ private static RevTree treeForBranch(GitCloneDirectory cloneDirectory, String br
if (cloneDirectory.remoteName == null) {
ref = branch;
} else {
Map<String, Ref> stringRefMap = cloneDirectory.git.lsRemote().setRemote(cloneDirectory.remoteName)
.callAsMap();
ref = stringRefMap.get("refs/heads/" + branch).getObjectId().name();
ref = cloneDirectory.git.getRepository().getRefDatabase()
.findRef("refs/remotes/%s/%s".formatted(cloneDirectory.remoteName, branch))
.getObjectId().name();
}
return GitUtils.firstExistingRevTree(cloneDirectory.git.getRepository(), ref);
} catch (IOException | GitAPIException e) {
} catch (IOException e) {
throw new RuntimeException("Unable to locate branch: " + cloneDirectory.details.branches.pages(), e);
}
}
Expand Down

0 comments on commit 8eeff0b

Please sign in to comment.