summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-30 01:48:17 -0600
committerJeff Carr <[email protected]>2025-01-30 01:48:17 -0600
commit57e38ee8ce56ba494c049a1dd10abb6c72fb1ca2 (patch)
tree791527a144869d0f24532bad7b9127ffa31419af
parent0bd0af48459479531fcce2d795587fce1fe6155d (diff)
just name fixups
-rw-r--r--autogen.go10
-rw-r--r--branches.go4
-rw-r--r--currentVersions.go37
-rw-r--r--reload.go16
-rw-r--r--reloadRepoType.go6
-rw-r--r--shell.go42
6 files changed, 44 insertions, 71 deletions
diff --git a/autogen.go b/autogen.go
index 977b0d0..7739e04 100644
--- a/autogen.go
+++ b/autogen.go
@@ -19,11 +19,11 @@ import (
func (repo *Repo) AutogenSave(files []string, refname string, del bool) error {
if del {
cmd := []string{"git", "notes", "show", refname}
- if err := repo.StrictRun(cmd); err != nil {
+ if _, err := repo.RunQuiet(cmd); err != nil {
// if there are not any notes, no need to remove them
} else {
cmd := []string{"git", "notes", "remove", refname}
- if err := repo.StrictRun(cmd); err != nil {
+ if _, err := repo.RunQuiet(cmd); err != nil {
return err
}
}
@@ -31,18 +31,18 @@ func (repo *Repo) AutogenSave(files []string, refname string, del bool) error {
for _, fname := range files {
autotag := "// `autogen:" + fname + "`"
cmd := []string{"git", "notes", "append", "-m", autotag, refname}
- if err := repo.StrictRun(cmd); err != nil {
+ if _, err := repo.RunQuiet(cmd); err != nil {
return err
}
cmd = []string{"git", "notes", "append", "-F", fname, refname}
- if err := repo.StrictRun(cmd); err != nil {
+ if _, err := repo.RunQuiet(cmd); err != nil {
return err
}
}
// a tag with a blank name indicates the end of the autogen file or files
autotag := "// `autogen:`"
cmd := []string{"git", "notes", "append", "-m", autotag, refname}
- if err := repo.StrictRun(cmd); err != nil {
+ if _, err := repo.RunQuiet(cmd); err != nil {
return err
}
return nil
diff --git a/branches.go b/branches.go
index 1c923dd..e6d0570 100644
--- a/branches.go
+++ b/branches.go
@@ -114,7 +114,7 @@ func (repo *Repo) GetHashName(h string) (string, error) {
h = strings.TrimSpace(h)
log.Info("GetHashName() is looking for", repo.GetGoPath(), h)
cmd := []string{"git", "describe", "--tags", h}
- r, err := repo.RunStrictNew(cmd)
+ r, err := repo.RunStrict(cmd)
if err != nil {
return "", err
}
@@ -128,7 +128,7 @@ func (repo *Repo) GetHashName(h string) (string, error) {
func (repo *Repo) GetTagHash(t string) string {
// git rev-list -n 1 v0.0.66
cmd := []string{"git", "rev-list", "-n", "1", t}
- result, _ := repo.RunStrictNew(cmd)
+ result, _ := repo.RunStrict(cmd)
// log.Info("getLastTagVersion()", result.Stdout)
if len(result.Stdout) == 0 {
diff --git a/currentVersions.go b/currentVersions.go
index 0f09cdf..6ddebda 100644
--- a/currentVersions.go
+++ b/currentVersions.go
@@ -69,19 +69,6 @@ func (repo *Repo) setUserVersion() {
}
}
-/*
-now tracked in repo.Reload()
-func (repo *Repo) GetCurrentBranchName() string {
- r := repo.RunQuiet([]string{"git", "branch", "--show-current"})
- output := strings.Join(r.Stdout, "\n")
- if r.Error != nil {
- log.Log(WARN, "GetCurrentBranchName() not in a git repo?", r.Error, repo.GetGoPath())
- log.Log(WARN, "GetCurrentBranchName() output might have worked anyway:", output)
- }
- return strings.TrimSpace(output)
-}
-*/
-
// this is used often. probably move everything to this
// returns things like
// v0.2.2
@@ -103,13 +90,13 @@ func (repo *Repo) gitDescribeByHash(hash string) (string, error) {
if hash == "" {
return "", errors.New("hash was blank")
}
- r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always", hash})
+ r, err := repo.RunQuiet([]string{"git", "describe", "--tags", "--always", hash})
out := strings.Join(r.Stdout, "\n")
- if r.Error != nil {
- log.Warn("not in a git repo or bad hash?", r.Error, repo.GetGoPath())
- return out, r.Error
+ if err != nil {
+ log.Warn("not in a git repo or bad hash?", err, repo.GetGoPath())
+ return out, err
}
- return out, r.Error
+ return out, err
}
// this should get the most recent tag
@@ -147,12 +134,12 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
if name == "" {
// git will return the current tag
- r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
+ r, err := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
output := strings.Join(r.Stdout, "\n")
- if r.Error != nil {
+ if err != nil {
log.Log(WARN, "gitDescribeByName() output might have worked anyway:", output)
- log.Log(WARN, "gitDescribeByName() not in a git repo?", r.Error, repo.GetGoPath())
- return "", r.Error
+ log.Log(WARN, "gitDescribeByName() not in a git repo?", err, repo.GetGoPath())
+ return "", err
}
return strings.TrimSpace(output), nil
}
@@ -162,11 +149,11 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name: " + name)
}
cmd := []string{"git", "describe", "--tags", "--always", name}
- result := repo.RunQuiet(cmd)
+ result, err := repo.RunQuiet(cmd)
output := strings.Join(result.Stdout, "\n")
- if result.Error != nil {
+ if err != nil {
log.Log(WARN, "cmd =", cmd)
- log.Log(WARN, "err =", result.Error)
+ log.Log(WARN, "err =", err)
log.Log(WARN, "output (might have worked with error?) =", output)
log.Log(WARN, "not in a git repo or bad tag?", repo.GetGoPath())
return "", result.Error
diff --git a/reload.go b/reload.go
index d43468e..47d5aa4 100644
--- a/reload.go
+++ b/reload.go
@@ -61,7 +61,7 @@ func (repo *Repo) SetUserBranchName(bname string) {
// updates LastTag // todo, get this from the protobuf
func (repo *Repo) setLastTag() {
cmd := []string{"git", "rev-list", "--tags", "--max-count=1"}
- result := repo.RunQuiet(cmd)
+ result, _ := repo.RunQuiet(cmd)
// log.Info("getLastTagVersion()", result.Stdout)
if len(result.Stdout) != 1 {
@@ -73,7 +73,7 @@ func (repo *Repo) setLastTag() {
hash := result.Stdout[0]
cmd = []string{"git", "describe", "--tags", "--always", hash}
- result = repo.RunQuiet(cmd)
+ result, _ = repo.RunQuiet(cmd)
if len(result.Stdout) != 1 {
log.Log(WARN, "git LastTag() error:", result.Stdout, "hash =", hash)
@@ -86,10 +86,10 @@ func (repo *Repo) setLastTag() {
func (repo *Repo) setCurrentBranchName() {
repo.CurrentBranchName = ""
- r := repo.RunQuiet([]string{"git", "branch", "--show-current"})
+ r, err := repo.RunQuiet([]string{"git", "branch", "--show-current"})
output := strings.Join(r.Stdout, "\n")
- if r.Error != nil {
- log.Log(WARN, "GetCurrentBranchName() not in a git repo?", r.Error, repo.GetGoPath())
+ if err != nil {
+ log.Log(WARN, "GetCurrentBranchName() not in a git repo?", err, repo.GetGoPath())
log.Log(WARN, "GetCurrentBranchName() output might have worked anyway:", output)
}
repo.CurrentBranchName = strings.TrimSpace(output)
@@ -102,10 +102,10 @@ func (repo *Repo) setCurrentBranchVersion() {
log.Info("repo.GetCurrentBranchVersion() repo == nil")
return
}
- r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
+ r, err := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
output := strings.Join(r.Stdout, "\n")
- if r.Error != nil {
- log.Log(WARN, "GetCurrentBranchVersion() not in a git repo?", r.Error, repo.GetGoPath())
+ if err != nil {
+ log.Log(WARN, "GetCurrentBranchVersion() not in a git repo?", err, repo.GetGoPath())
log.Log(WARN, "GetCurrentBranchVersion() output might have worked anyway:", output)
}
repo.CurrentBranchVersion = strings.TrimSpace(output)
diff --git a/reloadRepoType.go b/reloadRepoType.go
index 435b82e..0bca691 100644
--- a/reloadRepoType.go
+++ b/reloadRepoType.go
@@ -71,9 +71,9 @@ func (repo *Repo) goListRepoType() string {
// cmd := []string{"go", "list", "-f", "'{{.Name}}'"} // probably use this. this just prints out the package name
// cmd := []string{"go", "list", "-f", "'{{.ImportPath}}'"} // returns go.wit.com/lib/protobuf/gitpb
- result := repo.RunQuiet(cmd)
- if result.Error != nil {
- log.Warn("go list binary detect failed", result.Error)
+ result, err := repo.RunQuiet(cmd)
+ if err != nil {
+ log.Warn("go list binary detect failed", err)
return ""
}
output := strings.TrimSpace(strings.Join(result.Stdout, "\n"))
diff --git a/shell.go b/shell.go
index 8a51a36..d104eb8 100644
--- a/shell.go
+++ b/shell.go
@@ -25,11 +25,6 @@ func (repo *Repo) Run(cmd []string) cmd.Status {
return result
}
-func (repo *Repo) RunQuiet(cmd []string) cmd.Status {
- result := shell.PathRunQuiet(repo.FullPath, cmd)
- return result
-}
-
func (repo *Repo) RunEcho(cmd []string) cmd.Status {
result := shell.PathRunQuiet(repo.FullPath, cmd)
log.Log(NOW, "cmd:", repo.FullPath, cmd)
@@ -52,35 +47,26 @@ func (repo *Repo) RunRealtimeVerbose(cmd []string) cmd.Status {
return shell.PathRunRealtime(repo.GetFullPath(), cmd)
}
-// error if result.Error or if result.Exit != 0
-func (repo *Repo) RunStrict(cmd []string) error {
- return repo.StrictRun(cmd)
-}
-
-func (repo *Repo) StrictRun(cmd []string) error {
- result := repo.RunQuiet(cmd)
+func (repo *Repo) RunQuiet(cmd []string) (*cmd.Status, error) {
+ result := shell.RunQuiet(cmd)
if result.Error != nil {
log.Warn(repo.GetGoPath(), cmd, "wow. golang is cool. an os.Error:", result.Error)
- return result.Error
+ return &result, result.Error
}
if result.Exit != 0 {
- log.Warn(cmd, "failed with", result.Exit)
- return errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
+ // log.Warn(cmd, "failed with", result.Exit, repo.GetGoPath())
+ return &result, errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
}
- return nil
+ return &result, nil
}
-func (repo *Repo) RunStrictNew(cmd []string) (*cmd.Status, error) {
- result := repo.RunQuiet(cmd)
- if result.Error != nil {
- log.Warn(repo.GetGoPath(), cmd, "wow. golang is cool. an os.Error:", result.Error)
- return &result, result.Error
- }
- if result.Exit != 0 {
+func (repo *Repo) RunStrict(cmd []string) (*cmd.Status, error) {
+ result, err := repo.RunQuiet(cmd)
+ if err != nil {
log.Warn(cmd, "failed with", result.Exit, repo.GetGoPath())
- return &result, errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
+ return result, errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
}
- return &result, nil
+ return result, nil
}
func (repo *Repo) Exists(filename string) bool {
@@ -143,7 +129,7 @@ func (repo *Repo) RunAll(all [][]string) bool {
func (repo *Repo) RunStrictAll(all [][]string) (*cmd.Status, error) {
for _, cmd := range all {
log.Log(WARN, "doAll() RUNNING: cmd =", cmd)
- if result, err := repo.RunStrictNew(cmd); err != nil {
+ if result, err := repo.RunStrict(cmd); err != nil {
return result, err
}
}
@@ -152,7 +138,7 @@ func (repo *Repo) RunStrictAll(all [][]string) (*cmd.Status, error) {
func (repo *Repo) RunVerbose(cmd []string) (*cmd.Status, error) {
log.Info("Running:", repo.GetGoPath(), cmd)
- r, err := repo.RunStrictNew(cmd)
+ r, err := repo.RunStrict(cmd)
if err != nil {
log.Info("Error", cmd, err)
}
@@ -166,7 +152,7 @@ func (repo *Repo) RunVerbose(cmd []string) (*cmd.Status, error) {
}
func (repo *Repo) RunVerboseOnError(cmd []string) (*cmd.Status, error) {
- r, err := repo.RunStrictNew(cmd)
+ r, err := repo.RunStrict(cmd)
if err == nil {
return r, err
}