This commit is contained in:
Jeff Carr 2024-02-22 17:19:29 -06:00
parent cd5f1d9d0f
commit 359ebce26e
5 changed files with 34 additions and 6 deletions

View File

@ -44,7 +44,7 @@ func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
newgrid.NextRow() newgrid.NextRow()
// runs "git branch --all" // runs "git branch --all"
rs.gitBranchAll() // rs.gitBranchAll()
rs.showBranchesButton = newgrid.NewButton("find jcarr and devel", func() { rs.showBranchesButton = newgrid.NewButton("find jcarr and devel", func() {
if rs.TagExists("jcarr") { if rs.TagExists("jcarr") {

17
git.go
View File

@ -20,6 +20,10 @@ func (rs *RepoStatus) GetCurrentBranchVersion() string {
return rs.currentVersion.String() return rs.currentVersion.String()
} }
func (rs *RepoStatus) LastGitPull() (time.Time, error) {
return rs.mtime(".git/FETCH_HEAD")
}
func (rs *RepoStatus) Age() time.Duration { func (rs *RepoStatus) Age() time.Duration {
var t *Tag var t *Tag
t = rs.NewestTag() t = rs.NewestTag()
@ -35,6 +39,19 @@ func (rs *RepoStatus) Age() time.Duration {
return time.Since(tagTime) return time.Since(tagTime)
} }
func (rs *RepoStatus) GitPull() error {
var cmd []string
cmd = append(cmd, "git", "pull")
err, _, output := RunCmd(rs.realPath.String(), cmd)
if err == nil {
log.Log(REPOWARN,"git pull ran", rs.Path())
log.Log(REPOWARN,"git pull output", output)
} else {
log.Log(REPOWARN,"git pull error", rs.Path(), err)
}
return err
}
/* /*
// this isn't right // this isn't right
func (rs *RepoStatus) LastTagAge() (time.Time, string) { func (rs *RepoStatus) LastTagAge() (time.Time, string) {

View File

@ -40,10 +40,7 @@ func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
newgrid.NextRow() newgrid.NextRow()
newgrid.NewButton("git pull", func() { newgrid.NewButton("git pull", func() {
var cmd []string rs.GitPull()
cmd = append(cmd, "git", "pull")
err, b, output := RunCmd(rs.realPath.String(), cmd)
log.Warn("Did git pull here", err, b, output)
}) })
newgrid.NextRow() newgrid.NextRow()

10
unix.go
View File

@ -233,6 +233,16 @@ func (rs *RepoStatus) Exists(filename string) bool {
return false return false
} }
func (rs *RepoStatus) mtime(filename string) (time.Time, error) {
pathf := filepath.Join(rs.Path(), filename)
statf, err := os.Stat(pathf)
if err == nil {
return statf.ModTime(), nil
}
log.Log(REPOWARN, "mtime() error", pathf, err)
return time.Now(), err
}
// returns true if the file exists // returns true if the file exists
func Exists(file string) bool { func Exists(file string) bool {
_, err := os.Stat(file) _, err := os.Stat(file)

View File

@ -11,8 +11,12 @@ import (
func (rs *RepoStatus) gitBranchAll() { func (rs *RepoStatus) gitBranchAll() {
err, out := rs.RunCmd([]string{"git", "branch", "--all"}) err, out := rs.RunCmd([]string{"git", "branch", "--all"})
log.Log(WARN, "git branch failed string =", rs.String())
log.Log(WARN, "git branch failed realpath =", rs.realPath.String())
if err != nil { if err != nil {
log.Log(WARN, "git branch failed", rs.String()) log.Log(WARN, "git branch failed string =", rs.String())
log.Log(WARN, "git branch failed realpath =", rs.realPath.String())
return
} }
all := strings.Split(out, "\n") all := strings.Split(out, "\n")
for _, s := range all { for _, s := range all {