Skip to content

Commit

Permalink
Merge pull request #743 from self-five/buildkit-backport-5072-fetch-tags
Browse files Browse the repository at this point in the history
Backport upstream BuildKit commit for fetching commits on tags but not branches
  • Loading branch information
tianon authored Jun 24, 2024
2 parents 5bbb7c7 + 59e107d commit 202320e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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")
}

0 comments on commit 202320e

Please sign in to comment.