From 1248e21394afa41f5a5a42e843c3bd4cae71c5d6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 11 Jan 2024 15:56:50 -0600 Subject: update for new gui API Signed-off-by: Jeff Carr --- git.go | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'git.go') diff --git a/git.go b/git.go index ad549e0..f51efe9 100644 --- a/git.go +++ b/git.go @@ -45,6 +45,35 @@ func (rs *RepoStatus) populateTags() { // rs.tagsDrop.Set(rs.lasttagrev) } +/* +.git/refs/remotes +.git/refs/remotes/github +.git/refs/remotes/github/devel +.git/refs/remotes/github/main +.git/refs/remotes/origin +.git/refs/remotes/origin/devel +.git/refs/remotes/origin/main +.git/refs/remotes/origin/jcarr +.git/refs/heads +*/ + +func (rs *RepoStatus) getBranches() []string { + var all []string + var heads []string + var remotes []string + heads = listFiles(fullpath(rs.repopath + "/.git/refs/heads")) + remotes = listFiles(fullpath(rs.repopath + "/.git/refs/remotes")) + + all = heads + + all = append(all, remotes...) + + for _, branch := range all { + log.Warn("getBranches()", branch) + } + return all +} + func (rs *RepoStatus) checkDirty() bool { out := run(rs.repopath, "git", "diff-index HEAD") if out == "" { @@ -59,7 +88,7 @@ func (rs *RepoStatus) checkDirty() bool { } -func (rs *RepoStatus) checkoutBranch(branch string) { +func (rs *RepoStatus) checkoutBranch(level string, branch string) { if rs.checkDirty() { log.Warn("checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch) return @@ -70,13 +99,14 @@ func (rs *RepoStatus) checkoutBranch(branch string) { realname := rs.getCurrentBranchName() realversion := rs.getCurrentBranchVersion() log.Warn(rs.repopath, "realname =", realname, "realversion =", realversion) - if realname == "jcarr" { - rs.jcarrBranch.Set(realversion) - } - if realname == "devel" { - rs.develBranch.Set(realversion) - } - if realname == "master" { + + switch level { + case "master": rs.masterBranch.Set(realversion) + case "devel": + rs.develBranch.Set(realversion) + case "user": + rs.jcarrBranch.Set(realversion) + default: } } -- cgit v1.2.3