diff options
| author | Jeff Carr <[email protected]> | 2024-01-23 15:20:54 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-23 15:20:54 -0600 |
| commit | dae15b593174ed82ac0f5f8c7250cb765a2b7f64 (patch) | |
| tree | 8a826a328b34035805bb48218d12bb82a6697966 /git.go | |
| parent | 2f4cba36dddaf1b0cfeabb875527b03bdb75036b (diff) | |
Scan() everything functions
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 52 |
1 files changed, 20 insertions, 32 deletions
@@ -10,11 +10,11 @@ import ( ) func (rs *RepoStatus) String() string { - return rs.repopath + return rs.goSrcPath.String() } func (rs *RepoStatus) GetPath() string { - return rs.repopath + return rs.goSrcPath.String() } func (rs *RepoStatus) GetCurrentBranchName() string { @@ -30,27 +30,27 @@ func (rs *RepoStatus) GetLastTagVersion() string { } func (rs *RepoStatus) getCurrentBranchName() string { - out := run(rs.repopath, "git", "branch --show-current") + out := run(rs.realPath.String(), "git", "branch --show-current") log.Log(INFO, "getCurrentBranchName() =", out) rs.currentBranch.SetValue(out) return out } func (rs *RepoStatus) getCurrentBranchVersion() string { - out := run(rs.repopath, "git", "describe --tags") + out := run(rs.realPath.String(), "git", "describe --tags") log.Log(INFO, "getCurrentBranchVersion()", out) rs.currentVersion.SetValue(out) return out } func (rs *RepoStatus) getLastTagVersion() string { - out := run(rs.repopath, "git", "rev-list --tags --max-count=1") + out := run(rs.realPath.String(), "git", "rev-list --tags --max-count=1") log.Log(INFO, "getLastTagVersion()", out) rs.lasttagrev = out lastreal := "describe --tags " + out // out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1") - out = run(rs.repopath, "git", lastreal) + out = run(rs.realPath.String(), "git", lastreal) rs.lasttag.SetValue(out) rs.tagsDrop.SetText(out) // rs.lastLabel.SetText(out) @@ -58,7 +58,7 @@ func (rs *RepoStatus) getLastTagVersion() string { } func (rs *RepoStatus) populateTags() { - tmp := fullpath(rs.repopath + "/.git/refs/tags") + tmp := rs.realPath.String() + "/.git/refs/tags" log.Log(INFO, "populateTags() path =", tmp) for _, tag := range listFiles(tmp) { if rs.tags[tag] == "" { @@ -70,24 +70,12 @@ func (rs *RepoStatus) populateTags() { // rs.tagsDrop.SetText(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")) + heads = listFiles(rs.realPath.String() + "/.git/refs/heads") + remotes = listFiles(rs.realPath.String() + "/.git/refs/remotes") all = heads @@ -101,7 +89,7 @@ func (rs *RepoStatus) getBranches() []string { func (rs *RepoStatus) CheckDirty() bool { cmd := []string{"git", "diff-index", "--quiet", "HEAD"} - path := "/home/jcarr/go/src/" + rs.repopath + path := rs.realPath.String() err, b, out := RunCmd(path, cmd) if err != nil { log.Warn("CheckDirty() b =", b) @@ -114,36 +102,36 @@ func (rs *RepoStatus) CheckDirty() bool { } if b { log.Log(INFO, "CheckDirty() b =", b, "path =", path, "out =", out) - log.Log(INFO, "CheckDirty() no", rs.repopath) + log.Log(INFO, "CheckDirty() no", rs.realPath.String()) rs.dirtyLabel.SetValue("no") return false } - log.Log(INFO, "CheckDirty() true", rs.repopath) + log.Log(INFO, "CheckDirty() true", rs.realPath.String()) rs.dirtyLabel.SetValue("dirty") return true } func (rs *RepoStatus) CheckoutBranch(branch string) (string, string) { - // run(rs.repopath, "git", "checkout " + branch) + // run(rs.realPath.String(), "git", "checkout " + branch) realname := rs.getCurrentBranchName() realversion := rs.getCurrentBranchVersion() - log.Log(INFO, rs.repopath, "realname =", realname, "realversion =", realversion) + log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion) return realname, realversion } func (rs *RepoStatus) checkoutBranch(level string, branch string) { if rs.CheckDirty() { - log.Log(INFO, "checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch) + log.Log(INFO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch) return } - out := run(rs.repopath, "git", "checkout "+branch) - log.Log(INFO, rs.repopath, "git checkout "+branch, "returned", out) + out := run(rs.realPath.String(), "git", "checkout "+branch) + log.Log(INFO, rs.realPath.String(), "git checkout "+branch, "returned", out) realname := rs.getCurrentBranchName() realversion := rs.getCurrentBranchVersion() - log.Log(INFO, rs.repopath, "realname =", realname, "realversion =", realversion) + log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion) switch level { case "master": @@ -259,7 +247,7 @@ func (rs *RepoStatus) CheckBranches() bool { var hashCheck string var perfect bool = true all := rs.getBranches() - path := fullpath(rs.repopath + "/.git/refs/") + path := rs.realPath.String() + "/.git/refs/" for _, b := range all { parts := strings.Split(b, "/") rdir := "heads" @@ -286,7 +274,7 @@ func (rs *RepoStatus) CheckBranches() bool { } var cmd []string cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash) - _, _, output := RunCmd("/home/jcarr/go/src/"+rs.repopath, cmd) + _, _, output := RunCmd(rs.realPath.String(), cmd) // git show -s --format=%ci <hash> will give you the time // log.Log(INFO, fullfile) if hash == hashCheck { |
