Skip to content

Commit 3927e28

Browse files
committed
peel tags when resolving
1 parent 6f10484 commit 3927e28

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

infrastructure/src/main/java/scala/bench/GitWalker.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,16 @@ public static ObjectId resolve(String branch, Repository repo) {
118118
ObjectId id = repo.resolve("origin/" + branch);
119119
if (id == null) {
120120
id = repo.resolve("scala/" + branch); // name of the remote on jenkins, TODO add to config
121-
if (id == null) {
122-
ObjectId resolve = repo.resolve(branch);
123-
if (resolve == null) {
124-
throw new IllegalArgumentException("Cannot resolve: " + branch + " from " + repo);
125-
}
126-
return resolve;
127-
} else {
128-
return id;
129-
}
130-
} else {
131-
return id;
121+
if (id == null)
122+
id = repo.resolve(branch);
123+
}
124+
125+
if (id == null)
126+
throw new IllegalArgumentException("Cannot resolve: " + branch + " from " + repo);
127+
128+
// if `id` is a tag, `peel` goes from the tag object to the referenced commit object
129+
try (RevWalk w = new RevWalk(repo)) {
130+
return w.peel(w.parseAny(id)).getId();
132131
}
133132
} catch (IOException e) {
134133
throw new RuntimeException(e);

0 commit comments

Comments
 (0)