diff options
| author | Jeff Carr <[email protected]> | 2024-01-30 10:08:07 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-30 10:08:07 -0600 |
| commit | ca09e7cf477dd2694788cb3128dc31c08bbf5724 (patch) | |
| tree | 689a60d07b51811ef1cfd6ee6e97ffed99e0c25b /git.go | |
| parent | a05f6c35ce02cf53fe25453107d8a092665453d1 (diff) | |
just use and parse 'git status' as it's more accurate
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 33 |
1 files changed, 5 insertions, 28 deletions
@@ -90,7 +90,7 @@ func (rs *RepoStatus) getBranches() []string { } func (rs *RepoStatus) CheckDirty() bool { - cmd := []string{"git", "diff-index", "--quiet", "HEAD"} + cmd := []string{"git", "status"} path := rs.realPath.String() err, b, out := RunCmd(path, cmd) if err != nil { @@ -103,7 +103,10 @@ func (rs *RepoStatus) CheckDirty() bool { rs.dirtyLabel.SetValue("error") return true } - if b { + + last := out[strings.LastIndex(out, "\n")+1:] + + if last == "nothing to commit, working tree clean" { log.Log(INFO, "CheckDirty() b =", b, "path =", path, "out =", out) log.Log(INFO, "CheckDirty() no", rs.realPath.String()) rs.dirtyLabel.SetValue("no") @@ -118,32 +121,6 @@ func (rs *RepoStatus) CheckDirty() bool { log.Log(WARN, "CheckDirty() out =", out) log.Log(WARN, "CheckDirty() err =", err) - cmd = []string{"git", "status"} - err, b, out = RunCmd(path, cmd) - - log.Log(WARN, "CheckDirty() true", rs.realPath.String()) - log.Log(WARN, "CheckDirty() cmd =", cmd) - log.Log(WARN, "CheckDirty() b =", b) - log.Log(WARN, "CheckDirty() path =", path) - log.Log(WARN, "CheckDirty() out =", out) - log.Log(WARN, "CheckDirty() err =", err) - - cmd = []string{"git", "diff-index", "--quiet", "HEAD"} - err, b, out = RunCmd(path, cmd) - - log.Log(WARN, "CheckDirty() true", rs.realPath.String()) - log.Log(WARN, "CheckDirty() cmd =", cmd) - log.Log(WARN, "CheckDirty() b =", b) - log.Log(WARN, "CheckDirty() path =", path) - log.Log(WARN, "CheckDirty() out =", out) - log.Log(WARN, "CheckDirty() err =", err) - - if b { - log.Log(INFO, "CheckDirty() IS ACTUALLY CLEAN") - rs.dirtyLabel.SetValue("no") - return false - } - rs.dirtyLabel.SetValue("dirty") return true |
