diff options
| author | Jeff Carr <[email protected]> | 2024-12-01 00:49:25 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-01 00:49:25 -0600 |
| commit | 455ea31d70b3dfa95ca4f269e42cf6a8dcf5f0d9 (patch) | |
| tree | 0428289ba77c371caec9324731ce5e913683272a /checkDirty.go | |
| parent | 8a6fb6d442b3725459823644cf79bb1c4117e813 (diff) | |
checkDirty()v0.0.11
Diffstat (limited to 'checkDirty.go')
| -rw-r--r-- | checkDirty.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/checkDirty.go b/checkDirty.go new file mode 100644 index 0000000..0db0ff4 --- /dev/null +++ b/checkDirty.go @@ -0,0 +1,45 @@ +package gitpb + +// runs git, parses output +// types faster than you can + +import ( + "fmt" + "strings" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +func (repo *Repo) NoteChange(s string) { + log.Warn("NoteChange()", s) +} + +// just return the current value +func (repo *Repo) IsDirty() bool { + return repo.Dirty +} + +// actually os.Exec('git') +func (repo *Repo) CheckDirty() bool { + cmd := []string{"git", "status", "--porcelain"} + r := shell.PathRunLog(repo.FullPath, cmd, GITPB) + if r.Error != nil { + log.Warn("CheckDirty() status cmd =", cmd) + out := strings.Join(r.Stdout, "\n") + log.Warn("CheckDirty() status out =", out) + log.Warn("CheckDirty() status err =", r.Error) + log.Error(r.Error, "CheckDirty() git status error") + repo.NoteChange("git status is in error " + fmt.Sprint(r.Error)) + repo.Dirty = true + return true + } + + if len(r.Stdout) == 0 { + repo.Dirty = false + return false + } + repo.Dirty = true + return true + +} |
