diff options
| author | Jeff Carr <[email protected]> | 2024-12-17 01:15:31 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-17 01:15:31 -0600 |
| commit | 4bc95ad2684cb42159229b8198aa8a2377f80aa1 (patch) | |
| tree | 57c4b95880302bfd3a34d0cc3eec6ab79f1d0993 /currentVersions.go | |
| parent | c53da5a9a1da1b29db24d4e1ce2b294514d99ac2 (diff) | |
keep isolating use of os.Exec("git")
Diffstat (limited to 'currentVersions.go')
| -rw-r--r-- | currentVersions.go | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/currentVersions.go b/currentVersions.go index e844831..8b9d16f 100644 --- a/currentVersions.go +++ b/currentVersions.go @@ -14,29 +14,6 @@ import ( "go.wit.com/log" ) -func (repo *Repo) GetLastTag() string { - cmd := []string{"git", "rev-list", "--tags", "--max-count=1"} - result := repo.RunQuiet(cmd) - // log.Info("getLastTagVersion()", result.Stdout) - - if len(result.Stdout) != 1 { - log.Log(GITPBWARN, "git LastTag() error:", result.Stdout) - return "" - } - - hash := result.Stdout[0] - - cmd = []string{"git", "describe", "--tags", "--always", hash} - result = repo.RunQuiet(cmd) - - if len(result.Stdout) != 1 { - log.Log(GITPBWARN, "git LastTag() error:", result.Stdout) - return "" - } - - return result.Stdout[0] -} - func (repo *Repo) GetMasterVersion() string { bname := repo.GetMasterBranchName() v, err := repo.gitVersionByName(bname) @@ -78,6 +55,8 @@ func (repo *Repo) GetUserVersion() string { } } +/* +now tracked in repo.Reload() func (repo *Repo) GetCurrentBranchName() string { r := repo.RunQuiet([]string{"git", "branch", "--show-current"}) output := strings.Join(r.Stdout, "\n") @@ -87,6 +66,7 @@ func (repo *Repo) GetCurrentBranchName() string { } return strings.TrimSpace(output) } +*/ // this is used often. probably move everything to this // returns things like @@ -105,21 +85,6 @@ func (repo *Repo) GetCurrentVersion() string { return bver } -// always spawns 'git' and always should spawn 'git' -func (repo *Repo) GetCurrentBranchVersion() string { - if repo == nil { - log.Info("repo.GetCurrentBranchVersion() repo == nil") - return "" - } - r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"}) - output := strings.Join(r.Stdout, "\n") - if r.Error != nil { - log.Log(GITPBWARN, "GetCurrentBranchVersion() not in a git repo?", r.Error, repo.GoPath) - log.Log(GITPBWARN, "GetCurrentBranchVersion() output might have worked anyway:", output) - } - return strings.TrimSpace(output) -} - func (repo *Repo) gitDescribeByHash(hash string) (string, error) { if hash == "" { return "", errors.New("hash was blank") @@ -135,13 +100,7 @@ func (repo *Repo) gitDescribeByHash(hash string) (string, error) { // this should get the most recent tag func (repo *Repo) GetLastTagVersion() string { - r := repo.RunQuiet([]string{"git", "rev-list", "--tags", "--max-count=1"}) - hash := strings.Join(r.Stdout, "\n") - hash = strings.TrimSpace(hash) - log.Log(GITPB, "getLastTagVersion()", hash) - - name, _ := repo.gitDescribeByHash(hash) - return name + return repo.LastTag } func (repo *Repo) DebianReleaseVersion() string { |
