Skip to content

[6.0] Move the 'GitRepositoryProvider' to compare urls using their canonical representation, correctly accepting results where repositories only differ by '.git' #7809

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

Conversation

francescomikulis
Copy link
Contributor

@francescomikulis francescomikulis commented Jul 22, 2024

Cherry-pick #7741.

Short Explanation: Fixed an issue where repositories would be re-cloned each build rather than using the cache due to git validation errors.
Detailed Explanation: Validating the origin of checked-out repositories no longer ensures that the path extension (often .git) matches the repository's specifier, as different git clients inconsistently preserve the path extension of the remote. Moving to the CanonicalPackageURL also ensures that absolute paths are treated as urls with a file:// scheme, matching git's behavior.
Scope: Dependency resolution - helps re-use existing checkouts for repositories where the remotes only differ by path extension.
Risk: Ignoring inconsistencies in the path extension could lead to an inconsistent in-memory cache state, if subsystems are keeping references to un-canonicalized remotes as strings.
Testing: This change is accompanied by a series of new tests that ensure we preserve this behavior in the future.
Issue: rdar://129329704
Original PR: #7741

…l representation, correctly accepting results where repositories only differ by '.git' (#7741)

Resolving local package dependencies often outputs a warning:
<path> is not valid git repository for '<repo>', will fetch again.

The underlying issue is that updating packages with a local SCM path
dependency always fail, as the shell-based repository URL has a file://
scheme, while the absolute path string does not.

After this change we only compare the canonical URLs, which will resolve
the inconsistency of comparing strings without considering the scheme
and / or path extension.

Validating the origin of checked-out repositories no longer ensures that
the path extension (often .git) matches the repository's specifier, as
different git clients inconsistently preserve the path extension of the
remote. Moving to the CanonicalPackageURL also ensures that absolute
paths are treated as urls with a file:// scheme, matching git's
behavior.
@francescomikulis
Copy link
Contributor Author

@swift-ci please test

@francescomikulis
Copy link
Contributor Author

@swift-ci please test Windows platform

@francescomikulis francescomikulis merged commit fa04bac into release/6.0 Jul 23, 2024
5 checks passed
@francescomikulis francescomikulis deleted the cherry-pick-6.0-repository-provider-compare-urls-with-canonical-representation branch July 23, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants