Skip to content

Commit 19ca057

Browse files
authored
Merge pull request #15 from infosiftr/git-url-bug
Workaround "docker build giturl" requiring the url to end in ".git"
2 parents 1dd5f0a + 58539d6 commit 19ca057

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

meta.jq

+19-1
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,28 @@ def pull_command:
5353
end
5454
;
5555
# input: "build" object (with "buildId" top level key)
56+
# output: string "giturl" ("https://github.com/docker-library/golang.git#commit:directory), used for "docker buildx build giturl"
57+
def git_build_url:
58+
.source.entry
59+
| (
60+
.GitRepo
61+
| if (endswith(".git") | not) then
62+
if test("^https?://github.com/") then
63+
# without ".git" in the url "docker buildx build url" fails and tries to build the html repo page as a Dockerfile
64+
# https://github.com/moby/buildkit/blob/0e1e36ba9eb8142968b2c5cfa2f12549bf9246d9/util/gitutil/git_ref.go#L81-L87
65+
# https://github.com/docker/cli/issues/1738
66+
. + ".git"
67+
else
68+
error("\(.) does not end in '.git' so build will fail to recognize it as a Git URL")
69+
end
70+
else . end
71+
) + "#" + .GitCommit + ":" + .Directory
72+
;
73+
# input: "build" object (with "buildId" top level key)
5674
# output: string "build command" ("docker buildx build ..."), may be multiple lines, expects to run in Bash with "set -Eeuo pipefail"
5775
def build_command:
5876
normalized_builder as $builder
59-
| (.source.entry.GitRepo + "#" + .source.entry.GitCommit + ":" + .source.entry.Directory) as $buildUrl
77+
| git_build_url as $buildUrl
6078
| if $builder == "buildkit" then
6179
[
6280
(

0 commit comments

Comments
 (0)