diff options
Diffstat (limited to 'checkout.go')
| -rw-r--r-- | checkout.go | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/checkout.go b/checkout.go index 4b46841..eb4d98b 100644 --- a/checkout.go +++ b/checkout.go @@ -3,6 +3,7 @@ package gitpb import ( "fmt" "os" + "os/user" "path/filepath" "go.wit.com/log" @@ -42,12 +43,20 @@ func (repo *Repo) CheckoutDevel() bool { func (repo *Repo) CheckoutUser() error { bName := repo.GetUserBranchName() - // log.Info("attempting checkout user", repo.GetGoPath(), bName) - err := repo.createUserBranchNew(bName) - if err != nil { - log.Info("attempting checkout user error", repo.GetGoPath(), bName, err) + if bName == "uerr" { + usr, _ := user.Current() + repo.SetUserBranchName(usr.Username) + bName = usr.Username + log.Info("gitpb CheckoutUser() somehow got user 'uerr'") } - return err + + return repo.createUserBranch(bName) + /* + if err != nil { + log.Info("attempting checkout user error", repo.GetGoPath(), bName, err) + } + return err + */ } func (repo *Repo) BranchExists(bName string) bool { @@ -83,15 +92,16 @@ func (repo *Repo) checkoutBranch(bName string) bool { return true } -func (repo *Repo) createUserBranchNew(branch string) error { - if branch == "" || branch == "uerr" { - return fmt.Errorf("forge.gitpb logic err. branch name was: %s", branch) +// actually creates a local user branch +func (repo *Repo) createUserBranch(branch string) error { + if branch == "" { + // get the username here? + return fmt.Errorf("gitpb createuserBranch() logic err. git branch name can not be blank") } if repo.IsDirty() { // never change repos on dirty branches return fmt.Errorf("repo is dirty") } - // log.Info("forge.gitpb look for branch name was:", branch, repo.GetGoPath()) if repo.Exists(filepath.Join(".git/refs/heads", branch)) { var err error @@ -125,8 +135,6 @@ func (repo *Repo) createUserBranchNew(branch string) error { // return fmt.Errorf("repo must be on devel branch %s", repo.GetGoPath()) } - // log.Info("forge.gitpb try to create", branch, repo.GetGoPath()) - // create the branch from devel cmd := []string{"git", "branch", branch} if _, err := repo.RunVerboseOnError(cmd); err != nil { |
