git: use custom giturl type to preserve original remote#4326
Merged
tonistiigi merged 2 commits intomoby:masterfrom Oct 17, 2023
Merged
git: use custom giturl type to preserve original remote#4326tonistiigi merged 2 commits intomoby:masterfrom
tonistiigi merged 2 commits intomoby:masterfrom
Conversation
SCP-style URLs take the following format [1]: [user@]server:project.git These are used and handled by git, so we should have a full-parser for these, that return a custom URL type. [1]: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols Signed-off-by: Justin Chadwell <me@jedevc.com>
5f22d19 to
bb06eb5
Compare
alexcb
reviewed
Oct 12, 2023
alexcb
approved these changes
Oct 12, 2023
Collaborator
alexcb
left a comment
There was a problem hiding this comment.
thanks for the speedy fix!
bb06eb5 to
9a51bb0
Compare
This resolves a regression introduced in 50e75e3. In this previous patch, I'd incorrectly assumed that scp-like URLs can express a subset of "standard"-URLs and so we can always safely convert them for consistency. This isn't true - the URL "git@example.com:foo" should be resolved to the home directory of the host, however, the converted URL "ssh://git@example.com/foo" will be resolved to the root of the host. To resolve this, we need to not perform this conversion. However, we also need preserve the behaviour of firm distinction between SCP and normal URL types (so as to keep proper port parsing). To do this, we add a new GitURL type to the gitutil package. This new type contains all useful fields shared in common between the standard libraries url package and our custom scp-style url parsing package. This keeps the previous property of a single clean interface to all GitURLs, while also ensuring that we preserve the original URL to pass to the Git CLI (making sure we strip fragments out, which are used as buildkit-level metadata). As a side-effect of this, the client-side calling code for parsing git urls is simplified (so we don't have to do fragment wrangling at every call point). Signed-off-by: Justin Chadwell <me@jedevc.com>
tonistiigi
approved these changes
Oct 17, 2023
This was referenced Mar 15, 2024
|
Raising this for visibility (hope this is the right PR) - is this the expected behavior? temporalio/docker-builds#187 |
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.
Fixes #4322 (thanks for the report @alexcb!)
This resolves a regression introduced in #4142. In this previous patch, I'd incorrectly assumed that scp-like URLs can express a subset of "standard"-URLs and so we can always safely convert them for consistency. This isn't true - the URL
"git@example.com:foo"should be resolved to the home directory of the host, however, the converted URL"ssh://git@example.com/foo"will be resolved to the root directory.To resolve this, we need to not perform this conversion. However, we also need preserve the behaviour of firm distinction between SCP and normal URL types (so as to keep proper port parsing).
To do this, we add a new
GitURLtype to thegitutilpackage. This new type contains all useful fields shared in common between the standard libraries url package and our custom scp-style url parsing package. This keeps the previous property of a single clean interface to allGitURLs, while also ensuring that we preserve the original URL to pass to the Git CLI (making sure we strip fragments out, which are used as buildkit-level metadata).As a side-effect of this, the client-side calling code for parsing git urls is simplified (so we don't have to do fragment wrangling at every call point).
(Note: the diff for this seems quite large. This is due to the addition of new tests, as well as the new struct definition, as well as doc-comments on those, instead of massive changes in behavior.)