summaryrefslogtreecommitdiff
path: root/unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'unix.go')
-rw-r--r--unix.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/unix.go b/unix.go
index cc49efc..45a1cbc 100644
--- a/unix.go
+++ b/unix.go
@@ -6,6 +6,7 @@ import (
"os/exec"
"strings"
"regexp"
+ "errors"
"go.wit.com/log"
)
@@ -37,6 +38,7 @@ func run(path string, thing string, cmdline string) string {
return tmp
}
+// goes in one directory so it gets remote branch names
func listFiles(directory string) []string {
var files []string
fileInfo, err := os.ReadDir(directory)
@@ -46,7 +48,15 @@ func listFiles(directory string) []string {
}
for _, file := range fileInfo {
- if !file.IsDir() {
+ if file.IsDir() {
+ dirname := file.Name()
+ newdir, _ := os.ReadDir(directory + "/" + dirname)
+ for _, file := range newdir {
+ if ! file.IsDir() {
+ files = append(files, dirname + "/" + file.Name())
+ }
+ }
+ } else {
files = append(files, file.Name())
}
}
@@ -103,14 +113,14 @@ func splitVersion(version string) (a, b, c string) {
}
}
-func runCmd(path string, parts []string) (bool, string) {
+func runCmd(path string, parts []string) (error, bool, string) {
if len(parts) == 0 {
log.Warn("command line was empty")
- return false, ""
+ return errors.New("empty"), false, ""
}
if parts[0] == "" {
log.Warn("command line was empty")
- return false, ""
+ return errors.New("empty"), false, ""
}
thing := parts[0]
parts = parts[1:]
@@ -128,12 +138,12 @@ func runCmd(path string, parts []string) (bool, string) {
log.Error(err)
log.Warn("output was", output)
log.Warn("cmd exited with error", err)
- return false, string(output)
+ return err, false, string(output)
}
tmp := string(output)
tmp = strings.TrimSpace(tmp)
// Print the output
- return true, tmp
+ return nil, true, tmp
}