From 50eac0e70c985e9ebf9e0571da8eb9ecd9754dd0 Mon Sep 17 00:00:00 2001 From: Benoit Gagnon Date: Sun, 29 Sep 2019 17:24:47 -0400 Subject: [PATCH] move the extracted archive into place before exiting Install --- pkg/git.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/git.go b/pkg/git.go index fb6f153..25907e4 100644 --- a/pkg/git.go +++ b/pkg/git.go @@ -180,7 +180,14 @@ func (p *GitPackage) Install(ctx context.Context, name, dir, version string) (st r, err := os.Open(archiveFilepath) defer r.Close() if err == nil { + // Extract the sub-directory (if any) from the archive + // If none specified, the entire archive is unpacked err = gzipUntar(tmpDir, r, p.Source.Subdir) + + // Move the extracted directory to its final destination + if err == nil { + err = os.Rename(path.Join(tmpDir, p.Source.Subdir), destPath) + } } }