Fix MSITE-1033: AbstractDeployMojo.getTopLevelProject() returns wrong project for SCM URLs#7
Fix MSITE-1033: AbstractDeployMojo.getTopLevelProject() returns wrong project for SCM URLs#7
Conversation
|
@copilot different scheme (encapsulated in SCM URL) and subpath should be equal |
Done in commit b73fc21. Made |
…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
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)https://tohttp://scheme for proper comparison (since SVN is a hierarchical VCS where the same repository can be accessed via both protocols)Updating
getTopLevelProject()to use the extracted comparable URLs for site comparisonExamples
Before this fix:
After this fix:
Testing
Added comprehensive unit tests in
AbstractDeployMojoTestcovering:All tests pass (10 total, including 5 new tests).
Security
Backward Compatibility
Fully maintained - non-SCM URLs continue to work exactly as before.
Fixes apache#1033
Original prompt
Fixes #6
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.