Merge pull request #10590 from guyboltonking/gbk-fix-lockfile-suffix

Correctly handle repository data file paths that contain a component with the same suffix as the data file
pull/10765/head
Matthew Fisher 4 years ago committed by GitHub
commit f34005b00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,7 +119,7 @@ func (o *repoAddOptions) run(out io.Writer) error {
repoFileExt := filepath.Ext(o.repoFile)
var lockPath string
if len(repoFileExt) > 0 && len(repoFileExt) < len(o.repoFile) {
lockPath = strings.Replace(o.repoFile, repoFileExt, ".lock", 1)
lockPath = strings.TrimSuffix(o.repoFile, repoFileExt) + ".lock"
} else {
lockPath = o.repoFile + ".lock"
}

@ -48,7 +48,11 @@ func TestRepoAddCmd(t *testing.T) {
}
defer srv2.Stop()
tmpdir := ensure.TempDir(t)
tmpdir := filepath.Join(ensure.TempDir(t), "path-component.yaml/data")
err = os.MkdirAll(tmpdir, 0777)
if err != nil {
t.Fatal(err)
}
repoFile := filepath.Join(tmpdir, "repositories.yaml")
tests := []cmdTestCase{

Loading…
Cancel
Save