summaryrefslogtreecommitdiff
path: root/checkout.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-29 10:29:36 -0500
committerJeff Carr <[email protected]>2025-08-29 10:29:36 -0500
commitf585edc1925a778f82cd2db03316a42090d57f0f (patch)
tree55c5eb8a97bfdc8dd4fdafef6ce274b4bd2ee990 /checkout.go
parentd47d25e3a696bde60bdce135829ac9de3f3291d5 (diff)
minor syntax changesv0.0.109
Diffstat (limited to 'checkout.go')
-rw-r--r--checkout.go30
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 {