From ba839f55c78664aed74d4e910c197c2cf43dd04e Mon Sep 17 00:00:00 2001 From: Pablo Santiago Blum de Aguiar Date: Mon, 11 Aug 2014 18:20:54 -0300 Subject: [PATCH] Use named return values to ease function usage --- repository/repository.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repository/repository.go b/repository/repository.go index ece64f7..a31e0ab 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -499,7 +499,7 @@ func (*GitContentRetriever) GetTags(repo string) ([]Ref, error) { return tags, err } -func (*GitContentRetriever) TempClone(repo string) (string, func(), error) { +func (*GitContentRetriever) TempClone(repo string) (cloneDir string, cleanUp func(), err error) { gitPath, err := exec.LookPath("git") if err != nil { return "", nil, fmt.Errorf("Error when trying to clone repository %s (%s).", repo, err) @@ -509,19 +509,19 @@ func (*GitContentRetriever) TempClone(repo string) (string, func(), error) { if err != nil || !repoExists { return "", nil, fmt.Errorf("Error when trying to clone repository %s (Repository does not exist).", repo) } - cloneDir, err := ioutil.TempDir("", "gandalf_clone") + cloneDir, err = ioutil.TempDir("", "gandalf_clone") if err != nil { return "", nil, fmt.Errorf("Error when trying to clone repository %s (Could not create temporary directory).", repo) } - cleanup := func() { + cleanUp = func() { os.RemoveAll(cloneDir) } cmd := exec.Command(gitPath, "clone", repoDir, cloneDir) out, err := cmd.CombinedOutput() if err != nil { - return cloneDir, cleanup, fmt.Errorf("Error when trying to clone repository %s into %s (%s [%s]).", repo, cloneDir, err, out) + return cloneDir, cleanUp, fmt.Errorf("Error when trying to clone repository %s into %s (%s [%s]).", repo, cloneDir, err, out) } - return cloneDir, cleanup, nil + return cloneDir, cleanUp, nil } func (*GitContentRetriever) SetCommitter(cloneDir string, committer GitUser) error {