Skip to content

Commit

Permalink
Merge pull request #294 from marko-bekhta/fix/i293-change-how-ref-id-…
Browse files Browse the repository at this point in the history
…is-obtained

Change how git ref id is obtained
  • Loading branch information
marko-bekhta authored Jun 26, 2024
2 parents 5ea2d2e + 8eeff0b commit fdf8f40
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 fdf8f40

Please sign in to comment.