Skip to content

Commit

Permalink
Add patch for buildkit to fetch by commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit authored and tianon committed Oct 30, 2024
1 parent 7274d12 commit 612102b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions buildkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY \
backport-5372-sbom-args.patch \
backport-moby-48455-fix-riscv64-seccomp.patch \
containerd-arm64-v8.patch \
git-fetch-by-commit.patch \
git-no-submodules.patch \
mips64le.patch \
noclip.patch \
Expand Down
1 change: 1 addition & 0 deletions buildkit/Dockerfile.0.13
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY \
backport-5372-sbom-args.patch \
backport-moby-48455-fix-riscv64-seccomp.patch \
containerd-arm64-v8-pre-0.15.patch \
git-fetch-by-commit.patch \
git-no-submodules.patch \
mips64le-pre-0.16.patch \
noclip.patch \
Expand Down
1 change: 1 addition & 0 deletions buildkit/Dockerfile.rc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ENV BUILDKIT_VERSION 0.17.0-rc2

COPY \
containerd-arm64-v8.patch \
git-fetch-by-commit.patch \
git-no-submodules.patch \
mips64le.patch \
noclip.patch \
Expand Down
1 change: 1 addition & 0 deletions buildkit/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ COPY \
"backport-5372-sbom-args.patch": { until: "0.17" },
"backport-moby-48455-fix-riscv64-seccomp.patch": { until: "0.17" },
"containerd-arm64-v8.patch": { older: { "0.15": "containerd-arm64-v8-pre-0.15.patch" } },
"git-fetch-by-commit.patch": { },
"git-no-submodules.patch": { },
"mips64le.patch": { older: { "0.16": "mips64le-pre-0.16.patch" } },
"noclip.patch": { },
Expand Down
20 changes: 20 additions & 0 deletions buildkit/git-fetch-by-commit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Description: try fetching by commit, then regular fall back to deeper fetching
Forwarded: no

diff --git a/source/git/source.go b/source/git/source.go
index d139942fc..700982bd6 100644
--- a/source/git/source.go
+++ b/source/git/source.go
@@ -459,6 +459,12 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
// skip fetch if commit already exists
if _, err := git.Run(ctx, "cat-file", "-e", ref+"^{commit}"); err == nil {
doFetch = false
+ } else {
+ // try fetching commit directly
+ // TODO limit to known working git hosts?
+ if _, err := git.Run(ctx, "fetch", "origin", ref+":"); err == nil {
+ doFetch = false
+ }
}
}

0 comments on commit 612102b

Please sign in to comment.