summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--checkout.go15
-rw-r--r--common.go5
-rw-r--r--config.go5
-rw-r--r--currentVersions.go7
4 files changed, 12 insertions, 20 deletions
diff --git a/checkout.go b/checkout.go
index 5d56e87..edc508a 100644
--- a/checkout.go
+++ b/checkout.go
@@ -2,7 +2,6 @@ package gitpb
import (
"fmt"
- "os"
"os/user"
"path/filepath"
@@ -11,20 +10,6 @@ import (
func (repo *Repo) CheckoutMaster() bool {
bName := repo.GetMasterBranchName()
- if bName == "giterr" {
- cmd := []string{"git", "checkout", "main"} // todo: figure out main
- repo.RunVerboseOnError(cmd)
- os.Exit(-1)
- // TODO: try to fix this
- if repo.checkoutBranch("main") {
- repo.MasterBranchName = "main"
- return true
- } else {
- cmd := []string{"git", "checkout", "main"} // todo: figure out main
- repo.RunVerboseOnError(cmd)
- return false
- }
- }
if repo.checkoutBranch(bName) {
return true
}
diff --git a/common.go b/common.go
index 4c6dee6..11c2c6d 100644
--- a/common.go
+++ b/common.go
@@ -14,7 +14,10 @@ func (repo *Repo) SetMasterBranchName(s string) {
func (repo *Repo) GetGoPath() string {
if repo.GoInfo == nil {
- return ""
+ return repo.Namespace
+ }
+ if repo.GoInfo.GoPath == "" {
+ return repo.Namespace
}
return repo.GoInfo.GoPath
}
diff --git a/config.go b/config.go
index f110ace..9e10d20 100644
--- a/config.go
+++ b/config.go
@@ -19,6 +19,11 @@ func (all *Repos) ConfigSave(fname string) error {
return errors.New("gitpb.ConfigSave() repos == nil")
}
+ if _, s := filepath.Split(fname); s != "repos.pb" {
+ log.Infof("ConfigSave() filename '%s' invalid\n", fname)
+ return log.Errorf("ConfigSave() filename '%s' invalid\n", fname)
+ }
+
data, err := all.Marshal()
if err != nil {
log.Info("gitpb proto.Marshal() failed len", len(data), err)
diff --git a/currentVersions.go b/currentVersions.go
index fdedb74..48563f9 100644
--- a/currentVersions.go
+++ b/currentVersions.go
@@ -38,7 +38,6 @@ func (repo *Repo) setMasterVersion() {
repo.MasterVersion = v
} else {
log.Log(WARN, "gitpb.GitMasterVersion() error:", err)
- repo.MasterVersion = "giterr"
}
}
@@ -134,11 +133,11 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
if name == "" {
// git will return the current tag
- r, err := repo.RunQuiet([]string{"git", "describe", "--tags"})
+ cmd := []string{"git", "describe", "--tags"}
+ r, err := repo.RunQuiet(cmd)
output := strings.Join(r.Stdout, "\n")
if err != nil {
- log.Log(WARN, "gitDescribeByName() output might have worked anyway:", output)
- log.Log(WARN, "gitDescribeByName() not in a git repo?", err, repo.GetGoPath())
+ log.Log(WARN, repo.FullPath, "gitDescribeByName() ", output, err, cmd)
return "", err
}
return strings.TrimSpace(output), nil