@@ -294,7 +294,7 @@ private List<RevCommit> getCommitList(
294
294
final RevCommit to = toBoundary .getRevision ();
295
295
final LogCommand logCommand = this .git .log ().addRange (from , to );
296
296
if (pathFilters != null && !pathFilters .isEmpty ()) {
297
- for (String pathFilter : pathFilters ) {
297
+ for (final String pathFilter : pathFilters ) {
298
298
logCommand .addPath (pathFilter );
299
299
}
300
300
}
@@ -490,8 +490,16 @@ private void pruneCommitsPerTag(final Map<String, Set<GitCommit>> commitsPerTag)
490
490
}
491
491
492
492
private boolean isMappedToAnotherTag (
493
- final Map <String , String > tagPerCommitsHash , final String thisCommitHash ) {
494
- return tagPerCommitsHash .containsKey (thisCommitHash );
493
+ final Map <String , String > tagPerCommitsHash ,
494
+ final String thisCommitHash ,
495
+ final String thisTagName ) {
496
+ final String existingTagName = tagPerCommitsHash .get (thisCommitHash );
497
+ if (existingTagName == null ) {
498
+ /** It was not mapped. */
499
+ return false ;
500
+ }
501
+ /** If mapped, map it to the lowest version. Where it was first released. */
502
+ return isFirstTagSemanticallyHighest (thisTagName , existingTagName );
495
503
}
496
504
497
505
private String noteThatTheCommitWasMapped (
@@ -547,7 +555,7 @@ private void populateCommitPerTag(
547
555
final PriorityQueue <TraversalWork > moreWork )
548
556
throws Exception {
549
557
final String thisCommitHash = to .getName ();
550
- if (this .isMappedToAnotherTag (tagPerCommitsHash , thisCommitHash )) {
558
+ if (this .isMappedToAnotherTag (tagPerCommitsHash , thisCommitHash , currentTagName )) {
551
559
return ;
552
560
}
553
561
if (this .thisIsANewTag (tagPerCommitHash , thisCommitHash )) {
@@ -584,31 +592,32 @@ private boolean shouldPrioritizeNewWork(
584
592
final TraversalWork existingWork , final TraversalWork newWork ) {
585
593
final String existingTagName = existingWork .getCurrentTagName ();
586
594
final String newTagName = newWork .getCurrentTagName ();
587
- return shouldPrioritizeNewWork (existingTagName , newTagName );
595
+ return isFirstTagSemanticallyHighest (existingTagName , newTagName );
588
596
}
589
597
590
- static boolean shouldPrioritizeNewWork (final String existingTagName , final String newTagName ) {
591
- if (existingTagName == null && newTagName == null ) {
598
+ static boolean isFirstTagSemanticallyHighest (
599
+ final String firstTagName , final String secondTagName ) {
600
+ if (firstTagName == null && secondTagName == null ) {
592
601
return false ;
593
602
}
594
- if (existingTagName == null && newTagName != null ) {
603
+ if (firstTagName == null && secondTagName != null ) {
595
604
return true ;
596
605
}
597
- if (newTagName == null ) {
606
+ if (secondTagName == null ) {
598
607
return false ;
599
608
}
600
- if (existingTagName .equals (newTagName )) {
609
+ if (firstTagName .equals (secondTagName )) {
601
610
return false ;
602
611
}
603
- final boolean newTagIsSemantic = SemanticVersioning .isSemantic (newTagName );
612
+ final boolean newTagIsSemantic = SemanticVersioning .isSemantic (secondTagName );
604
613
if (newTagIsSemantic ) {
605
- final boolean existingTagNameIsSemantic = SemanticVersioning .isSemantic (existingTagName );
614
+ final boolean existingTagNameIsSemantic = SemanticVersioning .isSemantic (firstTagName );
606
615
if (!existingTagNameIsSemantic ) {
607
616
return true ;
608
617
}
609
618
final SemanticVersion highest =
610
- SemanticVersioning .getHighestVersion (Arrays .asList (existingTagName , newTagName ));
611
- if (highest .findTag ().orElse ("" ).equals (existingTagName )) {
619
+ SemanticVersioning .getHighestVersion (Arrays .asList (firstTagName , secondTagName ));
620
+ if (highest .findTag ().orElse ("" ).equals (firstTagName )) {
612
621
return true ;
613
622
}
614
623
}
@@ -653,7 +662,7 @@ private GitCommit toGitCommit(final RevCommit revCommit) {
653
662
merge );
654
663
}
655
664
656
- public void setPathFilters (List <String > pathFilters ) {
665
+ public void setPathFilters (final List <String > pathFilters ) {
657
666
this .pathFilters = pathFilters ;
658
667
}
659
668
0 commit comments