something to make user branches
This commit is contained in:
parent
1c43978294
commit
68af638f9e
26
branches.go
26
branches.go
|
@ -82,3 +82,29 @@ func (repo *Repo) DeleteLocalDevelBranch() error {
|
||||||
return fmt.Errorf("local branch has patches not in remote")
|
return fmt.Errorf("local branch has patches not in remote")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
master := repo.GetMasterBranchName()
|
||||||
|
cmd := []string{"git", "branch", branch, master}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
cmd = []string{"git", "checkout", branch}
|
||||||
|
repo.RunVerbose(cmd)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package gitpb
|
package gitpb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
@ -84,12 +85,11 @@ func (repo *Repo) checkoutBranch(bName string) bool {
|
||||||
|
|
||||||
func (repo *Repo) createUserBranchNew(branch string) error {
|
func (repo *Repo) createUserBranchNew(branch string) error {
|
||||||
if branch == "" || branch == "uerr" {
|
if branch == "" || branch == "uerr" {
|
||||||
log.Info("forge.gitpb logic err. branch name was:", branch)
|
return fmt.Errorf("forge.gitpb logic err. branch name was: %s", branch)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
if repo.IsDirty() {
|
if repo.IsDirty() {
|
||||||
// never change repos on dirty branches
|
// never change repos on dirty branches
|
||||||
return nil
|
return fmt.Errorf("repo is dirty")
|
||||||
}
|
}
|
||||||
// log.Info("forge.gitpb look for branch name was:", branch, repo.GetGoPath())
|
// log.Info("forge.gitpb look for branch name was:", branch, repo.GetGoPath())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue