Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: updates incorrectly reported in report overview #760

Closed
andrzejj0 opened this issue Oct 15, 2022 · 3 comments · Fixed by #761
Closed

Regression: updates incorrectly reported in report overview #760

andrzejj0 opened this issue Oct 15, 2022 · 3 comments · Fixed by #761
Labels
Milestone

Comments

@andrzejj0
Copy link
Contributor

    @Test
    public void testWrongReportBounds() throws IOException, MavenReportException
    {
        OutputStream os = new ByteArrayOutputStream();
        SinkFactory sinkFactory = new Xhtml5SinkFactory();
        new TestDependencyUpdatesReportMojo()
                .withOnlyUpgradable( true )
                .withDependencies(
                        dependencyOf( "test-artifact" ) )
                .withArtifactMetadataSource( mockArtifactMetadataSource(new HashMap<String, String[]>()
                {{
                   put( "test-artifact", new String[] { "1.0.0", "2.0.0-rc2" } );
                }} ) )
                .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() );

        String output = os.toString().replaceAll( "\\s*", "" );
        assertThat( output, allOf(
                containsString( "<td>report.overview.numNewerMajorAvailable</td><td>1</td>" ),
                containsString( "<td>report.overview.numUpToDate</td><td>0</td>" ) ) );
    }

For a project containing a non-release update, no updates are reported, but the update (2.0.0-rc2) will still be listed in updates.

@andrzejj0
Copy link
Contributor Author

The root cause is the fact that I was only adding "-snapshot" in incrementSegment to snapshot versions. This was initially done (before this "infinity calculus") because "-snapshot" is treated as the lowest possible version, lower than the release, which acts as a pseudo "minus infinity".

Well, I could either do that or introduce a real "minus infinity".

@sultan
Copy link
Contributor

sultan commented Oct 15, 2022

i would agree with this, even -1 is ok
we could use -1 in the int fields of the artifact version then 2.(-1) < 2.0,
any risks of unexpected results with strings though?

@andrzejj0
Copy link
Contributor Author

andrzejj0 commented Oct 15, 2022

i would agree with this, even -1 is ok we could use -1 in the int fields of the artifact version then 2.(-1) < 2.0, any risks of unexpected results with strings though?

No, that won't work -- ComparableVersion (the core class responsible for implementing Maven-style comparison) won't treat it correctly. But I'm almost done.

andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Oct 15, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Oct 15, 2022
andrzejj0 added a commit to andrzejj0/versions-maven-plugin that referenced this issue Oct 15, 2022
@slawekjaranowski slawekjaranowski linked a pull request Oct 15, 2022 that will close this issue
@slawekjaranowski slawekjaranowski added this to the 2.13.0 milestone Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants