Fix MSITE-1033: AbstractDeployMojo.getTopLevelProject() returns wrong project for SCM URLs#1177
Closed
slachiewicz wants to merge 3 commits intoapache:masterfrom
Closed
Fix MSITE-1033: AbstractDeployMojo.getTopLevelProject() returns wrong project for SCM URLs#1177slachiewicz wants to merge 3 commits intoapache:masterfrom
slachiewicz wants to merge 3 commits intoapache:masterfrom
Conversation
…roject Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
- Changed extractComparableUrl from private to package-private for testing - Added scheme normalization for SVN URLs (https -> http) to enable proper comparison - Added comprehensive test for SVN URLs with different schemes and subpaths - Test verifies that SVN URLs with http vs https are recognized as same site Co-authored-by: slachiewicz <6705942+slachiewicz@users.noreply.github.com>
1bff0e2 to
dbbb8f9
Compare
Member
|
Can't we rather fix #227? This change is obviously created by AI and doesn't properly leverage existing methods like |
Member
Author
|
Yes, sure we can fix - this was just an attempt to look In for a solution from a different direction . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
getTopLevelProject()method inAbstractDeployMojoincorrectly treats all SCM URLs as pointing to the same site, causing it to return the wrong top-level project when a project hierarchy uses different SCM URLs.For example, consider two projects:
scm:git:git@github.com:codehaus-plexus/plexus-sec-dispatcher.git/scm:git:https://github.com/codehaus-plexus/plexus-pom.git/These clearly point to different repositories, but the method incorrectly identifies them as the same site because SCM URLs are opaque URIs. When parsed as URIs, they only expose the scheme ("scm"), while host and port are both null, making all SCM URLs appear identical.
Solution
This PR fixes the issue by:
Adding maven-scm-api dependency to properly parse SCM URLs using
ScmUrlUtils.getProviderSpecificPart()Creating an
extractComparableUrl()helper method that:scm:)scm:git:https://github.com/user/repo.git→https://github.com/user/repo.git)git@github.com:user/repo.git) by converting it to a comparable format (ssh://github.com/user/repo.git)Updating
getTopLevelProject()to use the extracted comparable URLs for site comparisonExample
Before this fix:
After this fix:
Testing
Added comprehensive unit tests in
AbstractDeployMojoTestcovering:All tests pass (9 total, including 4 new tests).
Security
Backward Compatibility
Fully maintained - non-SCM URLs continue to work exactly as before.
Fixes #1159