Skip to content

git url: support CSV form (also support verifying a tag with a commit hash) #5903

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Apr 10, 2025

Commit 1: git url: support CSV form

CSV parameters can be now specified after "##" in a git URL. e.g.,

https://github.com/user/repo.git##ref=v1.0.0,subdir=/dir

Fix #4905, but the syntax differs from the original proposal.

The documents will be added in
https://github.com/docker/docs/blob/main/content/manuals/build/concepts/context.md#url-fragments

Commit 2: git url: support specifying ref and commit together

Fix #5871

}
if isHTTPSourceV {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Use git show --ignore-all-space to review)

@jedevc
Copy link
Member

jedevc commented Apr 10, 2025

🤔 Wondering why we use the fragment here actually. Wouldn't query parameters make more sense, since there's actually a way of having multiple params there?

So instead:

https://github.com/user/repo.git?tag=mytag&branch=main&commit=cafebab&subdir=/dir

It just feels a bit odd to overload the ##. But I suppose the format is a little tricky, so urgh, no strong opinions, just an idea.

@AkihiroSuda
Copy link
Member Author

Wondering why we use the fragment here actually. Wouldn't query parameters make more sense, since there's actually a way of having multiple params there?

Query params doesn't seem correct here, as it would be sent to the server as an HTTP GET request

@@ -6,6 +6,7 @@ const AttrAuthHeaderSecret = "git.authheadersecret"
const AttrAuthTokenSecret = "git.authtokensecret"
const AttrKnownSSHHosts = "git.knownsshhosts"
const AttrMountSSHSock = "git.mountsshsock"
const AttrCommitHash = "git.commithash"
Copy link
Member Author

@AkihiroSuda AkihiroSuda Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Bikeshedding: this could be also named AttrGitChecksum to follow AttrHTTPChecksum)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonistiigi Which one do you prefer?

@AkihiroSuda AkihiroSuda changed the title git url: support CSV form git url: support CSV form (also support verifying a tag with a commit hash) Apr 10, 2025
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should include existing features like keep-git-dir, #4905 (comment) . Also #4974 seems like a simple addition.

What if a branch/tag starts with #?

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Apr 12, 2025

I think we should include existing features like keep-git-dir, #4905 (comment) .

Can be another PR?

Also #4974 seems like a simple addition.

Can be another PR? Maybe not as easy as keep-git-dir.

What if a branch/tag starts with #?

https://example.com/repo.git##ref=#foohandles #foo as a valid branch/tag.
Updated the unit tests to cover it.

https://example.com/repo.git##foo will begin to fail, but nobody is likely affected?

CSV parameters can be now specified after "##" in a git URL.
e.g.,
https://github.com/user/repo.git##ref=v1.0.0,subdir=/dir

Fix issue 4905, but the syntax differs from the original proposal.

The documents will be added in
https://github.com/docker/docs/blob/main/content/manuals/build/concepts/context.md#url-fragments

Signed-off-by: Akihiro Suda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLB Git should allow branch/tag ref together with commit Proposal: csv syntax for git repos
3 participants