Skip to content

Commit 0c716fd

Browse files
authored
Merge pull request #6176 from tonistiigi/remove-ref-initialize
dfgitutil: don't initialize ref from checksum
2 parents 99a9103 + bb018e9 commit 0c716fd

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

frontend/dockerfile/dfgitutil/git_ref.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,5 @@ func (gf *GitRef) loadQuery(query url.Values) error {
176176
}
177177
gf.Ref = branch
178178
}
179-
if gf.Checksum != "" && gf.Ref == "" {
180-
gf.Ref = gf.Checksum
181-
}
182179
return nil
183180
}

frontend/dockerfile/dockerfile_addgit_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,26 @@ COPY foo out
472472
url: serverURL + "/.git?commit=" + commitHashV2,
473473
expectOut: "v0.0.2\n",
474474
},
475+
{
476+
name: "v2 by commit (wrong short)",
477+
url: serverURL + "/.git?commit=" + commitHashV2[:8],
478+
expectErr: "expected checksum to match",
479+
},
480+
{
481+
name: "v2 by commit (short)",
482+
url: serverURL + "/.git?commit=" + commitHashLatest[:8],
483+
expectOut: "latest\n",
484+
},
475485
{
476486
name: "v2 ref by commit",
477487
url: serverURL + "/.git?ref=" + commitHashV2,
478488
expectOut: "v0.0.2\n",
479489
},
490+
{
491+
name: "v2 ref by commit (short)",
492+
url: serverURL + "/.git?ref=" + commitHashV2[:8],
493+
expectErr: "repository does not contain ref",
494+
},
480495
{
481496
name: "tag with commit",
482497
url: serverURL + "/.git?tag=v0.0.2&commit=" + commitHashV2,

0 commit comments

Comments
 (0)