just name fixups
This commit is contained in:
parent
0bd0af4845
commit
57e38ee8ce
10
autogen.go
10
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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
16
reload.go
16
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)
|
||||
|
|
|
@ -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"))
|
||||
|
|
44
shell.go
44
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,37 +47,28 @@ 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)
|
||||
if result.Error != nil {
|
||||
log.Warn(repo.GetGoPath(), cmd, "wow. golang is cool. an os.Error:", result.Error)
|
||||
return result.Error
|
||||
}
|
||||
if result.Exit != 0 {
|
||||
log.Warn(cmd, "failed with", result.Exit)
|
||||
return errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *Repo) RunStrictNew(cmd []string) (*cmd.Status, 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, result.Error
|
||||
}
|
||||
if result.Exit != 0 {
|
||||
log.Warn(cmd, "failed with", result.Exit, repo.GetGoPath())
|
||||
// log.Warn(cmd, "failed with", result.Exit, repo.GetGoPath())
|
||||
return &result, errors.New(fmt.Sprint(cmd, "failed with", result.Exit))
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
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, nil
|
||||
}
|
||||
|
||||
func (repo *Repo) Exists(filename string) bool {
|
||||
if repo == nil {
|
||||
return false
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue