diff options
| author | Jeff Carr <[email protected]> | 2024-11-01 21:41:16 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-01 21:41:16 -0500 |
| commit | b45159100604ac62def0fd217f5f3ad5dd282c0d (patch) | |
| tree | 9b3a9d04d470d97ddba04587ae2c14f1c97901ce /git.go | |
| parent | bf2a42ec648df212836d0ab050ec3a38093e1f7a (diff) | |
DirtyList()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -188,9 +188,29 @@ func (rs *RepoStatus) IsDirty() bool { return true } +// return the list of dirty files (but ignores go.mod & go.sum) +func (rs *RepoStatus) DirtyList() []string { + var all []string + for _, line := range strings.Split(rs.dirtyList, "\n") { + line = strings.TrimSpace(line) + parts := strings.Split(line, " ") + if len(parts) != 2 { + continue + } + if parts[1] == "go.mod" { + continue + } + if parts[1] == "go.sum" { + continue + } + all = append(all, parts[1]) + } + return all +} + func (rs *RepoStatus) CheckDirty() bool { var start string = rs.dirtyLabel.String() - cmd := []string{"git", "status"} + cmd := []string{"git", "status", "--porcelain"} err, out := rs.RunCmd(cmd) if err != nil { log.Warn("CheckDirty() status cmd =", cmd) @@ -204,9 +224,12 @@ func (rs *RepoStatus) CheckDirty() bool { return true } - last := out[strings.LastIndex(out, "\n")+1:] + rs.dirtyList = out + + // last := out[strings.LastIndex(out, "\n")+1:] + // if last == "nothing to commit, working tree clean" { - if last == "nothing to commit, working tree clean" { + if len(rs.DirtyList()) == 0 { log.Log(REPO, "CheckDirty() no", rs.realPath.String()) rs.dirtyLabel.SetValue("no") if start == "" { |
