From b597b161733f4b62e200af40a342ef6c1b80fdd5 Mon Sep 17 00:00:00 2001 From: Benoit Gagnon Date: Sat, 28 Sep 2019 10:32:26 -0400 Subject: [PATCH] use filepath.Join instead of string concatenation --- pkg/git.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/git.go b/pkg/git.go index 2a2f6fe..d337824 100644 --- a/pkg/git.go +++ b/pkg/git.go @@ -212,7 +212,7 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st } } - // Sparse checkout optimization: if a Subdir is specificied, + // Sparse checkout optimization: if a Subdir is specified, // there is no need to do a full checkout if p.Source.Subdir != "" { cmd = exec.CommandContext(ctx, "git", "config", "core.sparsecheckout", "true") @@ -224,8 +224,12 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st if err != nil { return "", err } + glob := []byte(p.Source.Subdir + "/*\n") - ioutil.WriteFile(tmpDir+"/.git/info/sparse-checkout", glob, 0644) + err = ioutil.WriteFile(filepath.Join(tmpDir, ".git", "info", "sparse-checkout"), glob, 0644) + if err != nil { + return "", err + } } cmd = exec.CommandContext(ctx, "git", "-c", "advice.detachedHead=false", "checkout", version)