Fix changing branch of pins with 'git+ssh://' and 'xyz+https://' urls#1722
Merged
mosteo merged 1 commit intoJul 29, 2024
Merged
Conversation
45754ca to
23c2542
Compare
Member
AFAIR, this is because in the past some git versions found in the wild wouldn't have yet the option to check out a particular branch. I think it is safe to use this now when needed. |
mosteo
approved these changes
Jul 29, 2024
Member
|
Thanks for the comprehensive test |
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.
Currently, specifying the branch of pinned remote repositories fails for
git+ssh://urls. The requested branch is fetched correctly when alr build is first run (or after manually clearing the cache), but subsequent changes to thebranch =component of the pin inalire.tomlalways results in the default branch being checked out. The same bug is also observed with[^+]*\+https:urls.git+ssh://urls actually appear to be deprecated, but we should probably support them anyway.The issue manifests in the
Updateprocedure. This detects if the url has changed and, if so, it clears the cached copy and does a freshgit clone(presumably on the basis that a different url probably points to a different version of the repository, which may have diverged sufficiently that an update will fail).For some reason, this fresh
git clonealways checks out the default branch (callsCheckout, rather thanCheckout (Branch => Branch)). I'm not sure whether this is intended behaviour, but it is not ordinarily a problem asDeployalways seems to be called several times. As such:cloneof the default branchThis fails for
git+ssh://and[^+]*\+https:urls because theRepofunction (which constructs the url when performing theclone) removes the prefix. A change to the url is detected by comparing the appropriate line ingit config --list(here) with the string defined inalire.toml(here).git configreturns the form passed to theclonecommand (without the prefix), while the string inalire.tomlretains the fullgit+ssh://form. The net effect is that a pin with agit+ssh://url will always be treated as having changed (fromssh://togit+ssh://), and the default branch will always be used (for every call toDeploy).This pull request resolves the issue by substituting
git+ssh://→ssh://andxyz+https://→https://when readingalire.toml.