Skip to content

Commit

Permalink
mojohaus#632 Fix Bounds so lower and upper bounds keep milestones and…
Browse files Browse the repository at this point in the history
… rcs in the same majors when they are. Preliminary work before fixing mojohaus#632.
  • Loading branch information
sultan committed Sep 7, 2022
1 parent b14af60 commit 1b70f09
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,15 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null )
{
sink.lineBreak();
}
boolean bold = equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) )
boolean bold =
equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.MAJOR ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) );
|| equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) )
|| equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) )
|| equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) );
if ( bold )
{
safeBold();
Expand All @@ -444,37 +445,37 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null )
safeBold_();
sink.nonBreakingSpace();
safeItalic();
if ( equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) )
if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) ) )
{
sink.text( getText( "report.nextVersion" ) );
}
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) )
{
sink.text( getText( "report.latestSubIncremental" ) );
sink.text( getText( "report.latestMajor" ) );
}
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) )
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.MAJOR ) ) )
{
sink.text( getText( "report.nextIncremental" ) );
sink.text( getText( "report.nextMajor" ) );
}
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) ) )
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) ) )
{
sink.text( getText( "report.latestIncremental" ) );
sink.text( getText( "report.latestMinor" ) );
}
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) ) )
{
sink.text( getText( "report.nextMinor" ) );
}
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) ) )
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) ) )
{
sink.text( getText( "report.latestMinor" ) );
sink.text( getText( "report.latestIncremental" ) );
}
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.MAJOR ) ) )
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) )
{
sink.text( getText( "report.nextMajor" ) );
sink.text( getText( "report.nextIncremental" ) );
}
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) ) )
else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) )
{
sink.text( getText( "report.latestMajor" ) );
sink.text( getText( "report.latestSubIncremental" ) );
}
else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) )
{
sink.text( getText( "report.nextVersion" ) );
}

safeItalic_();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection<Depen
}
try
{
// TODO check whether true can be passed as forceSnapshot parameter.
ArtifactVersion upperBound =
segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null;
segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment, false ) : null;
getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) );
ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false );
getLog().debug( "Candidate versions " + Arrays.asList( newer ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection<Depende
}
try
{
// TODO check whether true can be passed as forceSnapshot parameter.
ArtifactVersion upperBound =
segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null;
segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment, false ) : null;
getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) );
ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false );
getLog().debug( "Candidate versions " + Arrays.asList( newer ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public final ArtifactVersion[] getNewerVersions( String versionString, int upper
ArtifactVersion lowerBound =
allowDowngrade ? getLowerBoundArtifactVersion( currentVersion, upperBoundSegment ) : currentVersion;
ArtifactVersion upperBound = upperBoundSegment == -1 ? null
: getVersionComparator().incrementSegment( lowerBound, upperBoundSegment );
: getVersionComparator().incrementSegment( lowerBound, upperBoundSegment, true );

return getVersions( lowerBound, upperBound, includeSnapshots, allowDowngrade, allowDowngrade );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert
ArtifactVersion upperBound = null;
if ( unchangedSegment != -1 )
{
upperBound = getVersionComparator().incrementSegment( lowerBoundArtifactVersion, unchangedSegment );
upperBound = getVersionComparator().incrementSegment( lowerBoundArtifactVersion, unchangedSegment, true );
helper.getLog().debug( "Property ${" + property.getName() + "}: upperBound is: " + upperBound );
}
ArtifactVersion result =
Expand Down Expand Up @@ -425,7 +425,7 @@ private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper
ArtifactVersion upperBound = null;
if ( segment != -1 )
{
upperBound = getVersionComparator().incrementSegment( lowerBound, segment );
upperBound = getVersionComparator().incrementSegment( lowerBound, segment, true );
}
return getNewestVersion( range, lowerBound, upperBound, includeSnapshots, false, false );
}
Expand Down Expand Up @@ -492,18 +492,19 @@ public int getSegmentCount( ArtifactVersion v )
return result;
}

public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException
public ArtifactVersion incrementSegment( ArtifactVersion v, int segment, boolean forceSnapshot )
throws InvalidSegmentException
{
if ( !isAssociated() )
{
throw new IllegalStateException( "Cannot compare versions for a property with no associations" );
}
VersionComparator[] comparators = lookupComparators();
assert comparators.length >= 1 : "we have at least one association => at least one comparator";
ArtifactVersion result = comparators[0].incrementSegment( v, segment );
ArtifactVersion result = comparators[0].incrementSegment( v, segment, forceSnapshot );
for ( int i = 1; i < comparators.length; i++ )
{
ArtifactVersion alt = comparators[i].incrementSegment( v, segment );
ArtifactVersion alt = comparators[i].incrementSegment( v, segment, forceSnapshot );
if ( !result.toString().equals( alt.toString() ) )
{
throw new IllegalStateException(
Expand Down
Loading

0 comments on commit 1b70f09

Please sign in to comment.