Skip to content

Commit fbbc190

Browse files
author
Vladimir Kotal
committed
use actual commit ID
1 parent 88f6365 commit fbbc190

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,23 @@ protected void buildTagList(File directory, CommandTimeoutType cmdType) {
628628
create(Paths.get(directory.getAbsolutePath(), ".git").toFile())) {
629629
try (Git git = new Git(repository)) {
630630
List<Ref> refList = git.tagList().call(); // refs sorted according to tag names
631-
Map<Ref, String> ref2Tags = new HashMap<>();
631+
Map<RevCommit, String> commit2Tags = new HashMap<>();
632632
for (Ref ref : refList) {
633633
String tagName = ref.getName().replace("refs/tags/", "");
634634
String existingTags;
635-
if ((existingTags = ref2Tags.get(ref)) != null) {
635+
RevCommit commit = getCommit(repository, ref);
636+
if ((existingTags = commit2Tags.get(commit)) != null) {
636637
existingTags = existingTags + TAGS_SEPARATOR + tagName;
637-
ref2Tags.put(ref, existingTags);
638+
commit2Tags.put(commit, existingTags);
638639
} else {
639-
ref2Tags.put(ref, tagName);
640+
commit2Tags.put(commit, tagName);
640641
}
641642
}
642643

643-
for (Map.Entry<Ref, String> entry : ref2Tags.entrySet()) {
644-
Date date = getCommitDate(repository, entry.getKey());
645-
GitTagEntry tagEntry = new GitTagEntry(entry.getKey().getObjectId().getName(),
644+
for (Map.Entry<RevCommit, String> entry : commit2Tags.entrySet()) {
645+
int commitTime = entry.getKey().getCommitTime();
646+
Date date = new Date((long) (commitTime) * 1000);
647+
GitTagEntry tagEntry = new GitTagEntry(entry.getKey().getName(),
646648
date, entry.getValue());
647649
this.tagList.add(tagEntry);
648650
}
@@ -659,13 +661,10 @@ protected void buildTagList(File directory, CommandTimeoutType cmdType) {
659661
}
660662

661663
@NotNull
662-
private Date getCommitDate(org.eclipse.jgit.lib.Repository repository, Ref ref) throws IOException {
663-
int commitTime;
664+
private RevCommit getCommit(org.eclipse.jgit.lib.Repository repository, Ref ref) throws IOException {
664665
try (RevWalk walk = new RevWalk(repository)) {
665-
RevCommit commit = walk.parseCommit(ref.getObjectId());
666-
commitTime = commit.getCommitTime();
666+
return walk.parseCommit(ref.getObjectId());
667667
}
668-
return new Date((long) (commitTime) * 1000);
669668
}
670669

671670
@Override

0 commit comments

Comments
 (0)