diff options
Diffstat (limited to 'branches.go')
| -rw-r--r-- | branches.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/branches.go b/branches.go index 3b642c1..378505e 100644 --- a/branches.go +++ b/branches.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - "go.wit.com/log" + "github.com/go-cmd/cmd" ) // returns true if 'git pull' will work @@ -72,10 +72,11 @@ func (repo *Repo) DeleteLocalDevelBranch() error { if !repo.IsDevelRemote() { return fmt.Errorf("no remote branch") } + b1 := repo.CountDiffObjects(branch, remote) // should be zero if b1 == 0 { cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()} - log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd) + // log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd) err := repo.RunVerbose(cmd) return err } else { @@ -85,26 +86,27 @@ func (repo *Repo) DeleteLocalDevelBranch() error { // makes a local branch based off of the master branch // (unless a remote devel branch exists. then it uses that) -func (repo *Repo) MakeLocalDevelBranch() error { +func (repo *Repo) MakeLocalDevelBranch() (*cmd.Status, error) { branch := repo.GetDevelBranchName() if branch == "" { // hard coded default branch = "devel" } + if repo.Exists(filepath.Join(".git/refs/heads", branch)) { // local devel branch already exists - return nil + return nil, nil } + if repo.Exists(filepath.Join(".git/refs/remotes/origin", branch)) { // remote devel branch exists, but local does not cmd := []string{"git", "checkout", branch} - repo.RunVerbose(cmd) - return nil + return repo.RunVerboseOnError(cmd) } + master := repo.GetMasterBranchName() cmd := []string{"git", "branch", branch, master} - repo.RunVerbose(cmd) + repo.RunVerboseOnError(cmd) cmd = []string{"git", "checkout", branch} - repo.RunVerbose(cmd) - return nil + return repo.RunVerboseOnError(cmd) } |
