From 9920aceb57dc74bc8ef12a5bc19cf0df8fa3e5ee Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Mon, 17 Nov 2014 12:06:56 +1100 Subject: [PATCH] x/tools/dashboard/builder: only write VERSION file if it doesn't exist LGTM=dsymonds R=dsymonds CC=golang-codereviews https://golang.org/cl/172610043 --- dashboard/builder/env.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dashboard/builder/env.go b/dashboard/builder/env.go index b97db998..199e4e6d 100644 --- a/dashboard/builder/env.go +++ b/dashboard/builder/env.go @@ -125,8 +125,12 @@ func (env *goEnv) setup(repo *Repo, workpath, hash string, envv []string) (strin if err := repo.Export(goworkpath, hash); err != nil { return "", fmt.Errorf("error exporting repository: %s", err) } - if err := ioutil.WriteFile(filepath.Join(goworkpath, "VERSION"), []byte(hash), 0644); err != nil { - return "", fmt.Errorf("error writing VERSION file: %s", err) + // Write out VERSION file if it does not already exist. + vFile := filepath.Join(goworkpath, "VERSION") + if _, err := os.Stat(vFile); os.IsNotExist(err) { + if err := ioutil.WriteFile(vFile, []byte(hash), 0644); err != nil { + return "", fmt.Errorf("error writing VERSION file: %s", err) + } } return filepath.Join(goworkpath, "src"), nil }