Skip to content

Commit 880bc0a

Browse files
author
Vladimir Kotal
committed
use more robust approach for obtaining commit ID + date for tags
fixes #2755
1 parent 455d807 commit 880bc0a

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

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

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -590,20 +590,20 @@ boolean hasFileBasedTags() {
590590
return true;
591591
}
592592

593-
private TagEntry buildTagEntry(File directory, String tags, boolean interactive) throws HistoryException, IOException {
593+
private TagEntry buildTagEntry(File directory, String tag, boolean interactive) {
594594
ArrayList<String> argv = new ArrayList<>();
595595
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
596596
argv.add(RepoCommand);
597597
argv.add("log");
598-
argv.add("--format=commit:%H" + System.getProperty("line.separator")
599-
+ "Date:%at");
600-
argv.add("-r");
601-
argv.add(tags + "^.." + tags);
598+
argv.add("--format=commit:%H%nDate:%at");
599+
argv.add("-n");
600+
argv.add("1");
601+
argv.add(tag);
602602

603603
Executor executor = new Executor(argv, directory, interactive ?
604604
RuntimeEnvironment.getInstance().getInteractiveCommandTimeout() :
605605
RuntimeEnvironment.getInstance().getCommandTimeout());
606-
GitTagParser parser = new GitTagParser(tags);
606+
GitTagParser parser = new GitTagParser(tag);
607607
executor.exec(true, parser);
608608
return parser.getEntries().first();
609609
}
@@ -645,21 +645,11 @@ protected void buildTagList(File directory, boolean interactive) {
645645
this.tagList = null;
646646
}
647647

648-
try {
649-
// Now get hash & date for each tag
650-
for (String tags : tagsList) {
651-
TagEntry tagEntry = buildTagEntry(directory, tags, interactive);
652-
// Reverse the order of the list
653-
this.tagList.add(tagEntry);
654-
}
655-
} catch (HistoryException e) {
656-
LOGGER.log(Level.WARNING,
657-
"Failed to parse tag list: {0}", e.getMessage());
658-
this.tagList = null;
659-
} catch (IOException e) {
660-
LOGGER.log(Level.WARNING,
661-
"Failed to read tag list: {0}", e.getMessage());
662-
this.tagList = null;
648+
// Now get hash & date for each tag.
649+
for (String tag : tagsList) {
650+
TagEntry tagEntry = buildTagEntry(directory, tag, interactive);
651+
// Reverse the order of the list
652+
this.tagList.add(tagEntry);
663653
}
664654
}
665655

0 commit comments

Comments
 (0)