Skip to content

Commit 490cfa3

Browse files
idodeclareVladimir Kotal
authored andcommitted
Fix to allow one-character tags
1 parent f6bdcf6 commit 490cfa3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class GitTagParser implements Executor.StreamHandler {
5151
* <p>d305482d0acf552ccd290d6133a52547b8da16be:1427209918:tag: 0.12.1.5:
5252
*/
5353
private static final Pattern PRETTY_TAG_MATCHER =
54-
Pattern.compile("tag:\\s+(\\S[^,:]+)(?:,\\s+|:)");
54+
Pattern.compile("tag:\\s+(\\S[^,:]*)(?:,\\s+|:)");
5555

5656
/**
5757
* Stores the externally provided set.

opengrok-indexer/src/test/java/org/opengrok/indexer/history/GitTagParserTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,21 @@ public void shouldParseOpenGrokTagsLog() throws IOException {
230230
assertEquals("tags should equal", t2.tags, floor2.tags);
231231
assertEquals("hashes should equal", t2.hash, ((GitTagEntry) floor2).hash);
232232
}
233+
234+
@Test
235+
public void shouldParseOneCharacterTags() throws IOException {
236+
final String LOG =
237+
"c6963a7ea2753672325502d342e653700be550a8:1377876557:tag: z:\n" +
238+
"c23e82b612acd5e947c164114377578116f6d298:1163621273::";
239+
final byte[] LOG_BYTES = LOG.getBytes(StandardCharsets.UTF_8);
240+
ByteArrayInputStream bytesIn = new ByteArrayInputStream(LOG_BYTES);
241+
242+
TreeSet<TagEntry> tagList = new TreeSet<>();
243+
GitTagParser parser = new GitTagParser(tagList);
244+
parser.processStream(bytesIn);
245+
246+
// See comment about LF count in shouldParseOpenGrokTagsLog().
247+
long countLF = LOG.chars().filter(ch -> ch == '\n').count();
248+
assertEquals("size should == LF count", countLF, tagList.size());
249+
}
233250
}

0 commit comments

Comments
 (0)