Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Use named return values to ease function usage
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Aug 11, 2014
1 parent b8bcdaa commit ba839f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit ba839f5

Please sign in to comment.