diff options
| -rw-r--r-- | branches.go | 8 | ||||
| -rw-r--r-- | gitTag.common.go | 16 |
2 files changed, 19 insertions, 5 deletions
diff --git a/branches.go b/branches.go index 7b256bb..b656522 100644 --- a/branches.go +++ b/branches.go @@ -107,17 +107,15 @@ func (repo *Repo) MakeLocalDevelBranch() (*cmd.Status, error) { branch = "devel" } - if repo.Exists(filepath.Join(".git/refs/heads", branch)) { - // local devel branch already exists + if repo.IsLocalBranch(branch) { return nil, nil } - - if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) { - // remote devel branch exists, but local does not + if repo.IsRemoteBranch(branch) { cmd := []string{"git", "checkout", branch} return repo.RunVerboseOnError(cmd) } + // no local or remote devel branch. make the branch from 'master' master := repo.GetMasterBranchName() cmd := []string{"git", "branch", branch, master} repo.RunVerboseOnError(cmd) diff --git a/gitTag.common.go b/gitTag.common.go index df78273..20fe31a 100644 --- a/gitTag.common.go +++ b/gitTag.common.go @@ -140,6 +140,22 @@ func (repo *Repo) IsLocalBranch(findname string) bool { return false } +func (repo *Repo) IsRemoteBranch(findname string) bool { + for t := range repo.Tags.IterAll() { + if !strings.HasPrefix(t.Refname, "refs/remotes/origin") { + continue + } + path, filename := filepath.Split(t.Refname) + log.Log(INFO, "gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath()) + if filename == findname { + log.Log(INFO, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GetGoPath()) + return true + } + } + log.Log(INFO, "did not find tag:", findname, "in", repo.GetGoPath()) + return false +} + // finds the newest tag. used for deciding if master needs to be published func (repo *Repo) FindLastTag() string { var newest *GitTag |
