diff options
| author | Jeff Carr <[email protected]> | 2024-01-23 10:52:17 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-23 10:52:17 -0600 |
| commit | 294119e7c2678b609aa8b66b6ffc219f1c399309 (patch) | |
| tree | 1a0b9e7de365e6540d0b3f9cc762a852472e32f6 /unix.go | |
| parent | 7546209d24055bb1252ba3cab63e09f692c3e74b (diff) | |
buttons for scanning .git/config and go.sum
common branch handling
scan go.sum & .git/config on New()
parse go & git config files
cleaner debugging
cleaning up logging
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'unix.go')
| -rw-r--r-- | unix.go | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -27,16 +27,17 @@ func run(path string, thing string, cmdline string) string { // Execute the command output, err := cmd.CombinedOutput() + tmp := string(output) + tmp = strings.TrimSpace(tmp) + if err != nil { + log.Log(WARN, "run()", path, thing, cmdline, "=", tmp) log.Error(err, "cmd error'd out", parts) return "" } - tmp := string(output) - tmp = strings.TrimSpace(tmp) - // Print the output - log.Log(WARN, "run()", path, thing, cmdline, "=", tmp) + log.Log(INFO, "run()", path, thing, cmdline, "=", tmp) return tmp } @@ -100,7 +101,7 @@ func normalizeVersion(s string) string { return parts[0] } clean := reg.ReplaceAllString(parts[0], "") - log.Log(WARN, "normalizeVersion() s =", clean) + log.Log(INFO, "normalizeVersion() s =", clean) return clean } @@ -134,8 +135,8 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) { } thing := parts[0] parts = parts[1:] + log.Log(INFO, "working path =", workingpath, "thing =", thing, "cmdline =", parts) - log.Warn("working path =", workingpath, "thing =", thing, "cmdline =", parts) // Create the command cmd := exec.Command(thing, parts...) @@ -145,9 +146,25 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) { // Execute the command output, err := cmd.CombinedOutput() if err != nil { + if thing == "git" { + log.Log(INFO, "git ERROR. maybe okay", workingpath, "thing =", thing, "cmdline =", parts) + log.Log(INFO, "git ERROR. maybe okay err =", err) + if err.Error() == "exit status 1" { + log.Log(INFO, "git ERROR. normal exit status 1") + if parts[0] == "diff-index" { + log.Log(INFO, "git normal diff-index when repo dirty") + return nil, false, "git diff-index exit status 1" + } + } + } + + log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts) + log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts) + log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts) log.Error(err) log.Warn("output was", string(output)) log.Warn("cmd exited with error", err) + // panic("fucknuts") return err, false, string(output) } @@ -159,12 +176,11 @@ func RunCmd(workingpath string, parts []string) (error, bool, string) { } // Set the path to the package -// Replace this with the actual path to the github.com/coredns/coredns directory func getfiles(pathToPackage string) { // List files in the directory err := filepath.Walk(pathToPackage, nil) // compiles but crashes if err == nil { - log.Warn("directory ok", pathToPackage) + log.Log(INFO, "directory ok", pathToPackage) } else { log.Warn("directory wrong", pathToPackage) } @@ -189,6 +205,6 @@ func VerifyLocalGoRepo(gorepo string) bool { // Form the path to the home Git directory gitDir := filepath.Join(usr.HomeDir, "go/src/", gorepo, ".git") - log.Warn("go directory:", gitDir) + log.Log(INFO, "go directory:", gitDir) return IsDirectory(gitDir) } |
