Skip to content
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

Backport upstream BuildKit commit for fetching commits on tags but not branches #743

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ FROM --platform=$BUILDPLATFORM golang:1.21 AS build
ENV BUILDKIT_VERSION 0.14.1

COPY \
backport-5072-fetch-tags.patch \
containerd-arm64-v8.patch \
git-no-submodules.patch \
mips64le.patch \
Expand Down
1 change: 1 addition & 0 deletions buildkit/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM --platform=$BUILDPLATFORM golang:{{ .go.version }} AS build
ENV BUILDKIT_VERSION {{ .version }}
COPY \
backport-5072-fetch-tags.patch \
containerd-arm64-v8.patch \
git-no-submodules.patch \
mips64le.patch \
Expand Down
16 changes: 16 additions & 0 deletions buildkit/backport-5072-fetch-tags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Subject: git: fix pulling commit SHA only referenced from a tag
Author: Tonis Tiigi <[email protected]>
Applied-Upstream: 0.15+; https://github.com/moby/buildkit/pull/5072

diff --git a/source/git/source.go b/source/git/source.go
index 998ede24ea4e..1b757500d7a3 100644
--- a/source/git/source.go
+++ b/source/git/source.go
@@ -470,6 +470,7 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
if !isCommitSHA(ref) { // TODO: find a branch from ls-remote?
args = append(args, "--depth=1", "--no-tags")
} else {
+ args = append(args, "--tags")
if _, err := os.Lstat(filepath.Join(gitDir, "shallow")); err == nil {
args = append(args, "--unshallow")
}
Loading