From 5775e3c0b79b5598fd4016ca6ba6afd3cf4a24cc Mon Sep 17 00:00:00 2001 From: morganamilo Date: Sun, 10 Jun 2018 00:42:58 +0100 Subject: [PATCH] Split git clone/pull and merge function --- download.go | 6 +++++- install.go | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/download.go b/download.go index 6bba35b9..7d761cf9 100644 --- a/download.go +++ b/download.go @@ -71,7 +71,11 @@ func gitDownload(url string, path string, name string) error { return fmt.Errorf("error fetching %s", name) } - err = passToGit(filepath.Join(path, name), "reset", "--hard", "HEAD") + return nil +} + +func gitMerge(url string, path string, name string) error { + err := passToGit(filepath.Join(path, name), "reset", "--hard", "HEAD") if err != nil { return fmt.Errorf("error resetting %s", name) } diff --git a/install.go b/install.go index 4ab48e31..8b45885d 100644 --- a/install.go +++ b/install.go @@ -636,10 +636,16 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r var err error if shouldUseGit(filepath.Join(config.BuildDir, pkg.PackageBase)) { - err = gitDownload(baseURL+"/"+pkg.PackageBase+".git", config.BuildDir, pkg.PackageBase) + err = gitDownload(baseURL + "/" + pkg.PackageBase + ".git", config.BuildDir, pkg.PackageBase) if err != nil { return hashes, err } + + err = gitMerge(baseURL + "/" + pkg.PackageBase + ".git", config.BuildDir, pkg.PackageBase) + if err != nil { + return hashes, err + } + } else { err = downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir) }