diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 02:48:03 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 02:48:03 -0500 |
| commit | d91fa140ba3808b056ca2c2aed126a978601dfe3 (patch) | |
| tree | 5230e1757df7187c706d27cbdeac141dcc442c33 /common.go | |
| parent | 966c40f2c4c80fcecc8d451293b6d512bc9f6d91 (diff) | |
common 'git commit' function
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1,5 +1,12 @@ package gitpb +import ( + "os" + + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + func (repo *Repo) SetReadOnly(b bool) { repo.ReadOnly = b } @@ -56,3 +63,27 @@ func (repo *Repo) IsDevelBranch() bool { } return false } + +func (repo *Repo) GitCommit() error { + if !repo.CheckDirty() { + // repo is not dirty. nothing to do! + return nil + } + os.Chdir(repo.GetFullPath()) + + os.Setenv("LESS", "-XR") + if err := shell.Exec([]string{"git", "diff"}); err != nil { + return err + } + + if err := shell.ExecCheck([]string{"git", "add", "--all"}); err != nil { + return err + } + + if err := shell.ExecCheck([]string{"git", "commit", "--all"}); err != nil { + shell.ExecCheck([]string{"git", "reset"}) + return err + } + log.Info("git commit ok.") + return nil +} |
