diff options
Diffstat (limited to 'doGit.go')
| -rw-r--r-- | doGit.go | 76 |
1 files changed, 44 insertions, 32 deletions
@@ -6,12 +6,56 @@ package main import ( "os" "path/filepath" + "strings" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) +func doGit() error { + log.DaemonMode(true) + defer log.DaemonMode(false) + + if argv.Git.Log != nil { + fstr := "--format=\"%h %>(24)%ar %>(20)%an %s" + cmd := []string{"git", "log", fstr} + shell.RunVerbose(cmd) + okExit("") + } + + if argv.Git.Tag != nil { + cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format"} + cmd = append(cmd, "%(tag)%00%(taggerdate:raw)%00%(taggername)%00%(subject)") + cmd = append(cmd, "refs/tags") + result := shell.RunQuiet(cmd) + for i, line := range result.Stdout { + parts := strings.Split(line, "\x00") + log.Infof("LINE: %d %v\n", i, parts) + } + } + + if argv.Git.Who != nil { + cmd := []string{"git", "who"} + shell.RunVerbose(cmd) + okExit("") + } + + if argv.Git.Pull != nil { + doPull(".config/wit") + doPull("tools") + okExit("") + } + + if argv.Git.Push != nil { + doPush(".config/wit") + doPush("tools") + okExit("") + } + + return nil +} + func findRepo(wpath string) (*gitpb.Repo, bool) { d := filepath.Join(me.homedir, wpath) if !shell.IsDir(d) { @@ -56,35 +100,3 @@ func doPush(wpath string) { repo.RunRealtime([]string{"git", "push"}) } - -func doGit() error { - log.DaemonMode(true) - defer log.DaemonMode(false) - - if argv.Git.Log != nil { - fstr := "--format=\"%h %>(24)%ar %>(20)%an %s" - cmd := []string{"git", "log", fstr} - shell.RunVerbose(cmd) - okExit("") - } - - if argv.Git.Who != nil { - cmd := []string{"git", "who"} - shell.RunVerbose(cmd) - okExit("") - } - - if argv.Git.Pull != nil { - doPull(".config/wit") - doPull("tools") - okExit("") - } - - if argv.Git.Push != nil { - doPush(".config/wit") - doPush("tools") - okExit("") - } - - return nil -} |
