Skip to content

Commit 77d2325

Browse files
author
Aaron Schlesinger
committed
ref(build.go): refactor the .tar.gz string into a commonly used variable
1 parent 0e75b6d commit 77d2325

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ func build(conf *Config, builderKey, gitSha string) error {
107107
}
108108

109109
// build a tarball from the new objects
110-
gitArchiveCmd := repoCmd(repoDir, "git", "archive", "--format=tar.gz", fmt.Sprintf("--output=%s.tar.gz", appName), gitSha)
110+
appTgz := fmt.Sprintf("%s.tar.gz", appName)
111+
gitArchiveCmd := repoCmd(repoDir, "git", "archive", "--format=tar.gz", fmt.Sprintf("--output=%s", appTgz), gitSha)
111112
gitArchiveCmd.Stdout = os.Stdout
112113
gitArchiveCmd.Stderr = os.Stderr
113114
if err := run(gitArchiveCmd); err != nil {
114115
return fmt.Errorf("running %s (%s)", strings.Join(gitArchiveCmd.Args, " "), err)
115116
}
116117

117118
// untar the archive into the temp dir
118-
tarCmd := repoCmd(repoDir, "tar", "-xzf", fmt.Sprintf("%s.tar.gz", appName), "-C", fmt.Sprintf("%s/", tmpDir))
119+
tarCmd := repoCmd(repoDir, "tar", "-xzf", appTgz, "-C", fmt.Sprintf("%s/", tmpDir))
119120
tarCmd.Stdout = os.Stdout
120121
tarCmd.Stderr = os.Stderr
121122
if err := run(tarCmd); err != nil {
@@ -194,10 +195,10 @@ func build(conf *Config, builderKey, gitSha string) error {
194195
// https://github.com/deis/builder/issues/80 will eliminate this distaste
195196
run(makeBucketCmd)
196197

197-
cpCmd := mcCmd(configDir, "cp", fmt.Sprintf("%s.tar.gz", appName), tarURL)
198+
cpCmd := mcCmd(configDir, "cp", appTgz, tarURL)
198199
cpCmd.Dir = repoDir
199200
if err := run(cpCmd); err != nil {
200-
return fmt.Errorf("copying %s.tar.gz to %s (%s)", appName, tarURL, err)
201+
return fmt.Errorf("copying %s to %s (%s)", appTgz, tarURL, err)
201202
}
202203

203204
log.Info("Starting build")

0 commit comments

Comments
 (0)