Skip to content

Commit 251dd10

Browse files
arschlesAaron Schlesinger
authored andcommitted
feat(build.go): add two utility functions
one for executing `mc` commands, one for debug logging the command and running it in one
1 parent d22940d commit 251dd10

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ func repoCmd(repoDir, first string, others ...string) *exec.Cmd {
3535
return cmd
3636
}
3737

38+
// mcCmd returns a command to execute the 'mc' binary, so that it reads config from configDir.
39+
// the command outputs its stderr to os.Stderr
40+
func mcCmd(configDir string, args ...string) *exec.Cmd {
41+
cmd := exec.Command("mc", "-C", configDir, "--quiet")
42+
cmd.Stderr = os.Stderr
43+
return cmd
44+
}
45+
46+
// run prints the command it will execute to the debug log, then runs it and returns the result of run
47+
func run(cmd *exec.Cmd) error {
48+
log.Debug("running [%s] in directory %s", strings.Join(cmd.Args, " "), cmd.Dir)
49+
return cmd.Run()
50+
}
51+
3852
func build(conf *Config, builderKey, gitSha string) error {
3953
// HTTP_PREFIX="http"
4054
// REMOTE_STORAGE="0"

0 commit comments

Comments
 (0)