summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-01 21:41:16 -0500
committerJeff Carr <[email protected]>2024-11-01 21:41:16 -0500
commitb45159100604ac62def0fd217f5f3ad5dd282c0d (patch)
tree9b3a9d04d470d97ddba04587ae2c14f1c97901ce /git.go
parentbf2a42ec648df212836d0ab050ec3a38093e1f7a (diff)
DirtyList()
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
-rw-r--r--git.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/git.go b/git.go
index 6e05316..e712e4d 100644
--- a/git.go
+++ b/git.go
@@ -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 == "" {