diff options
| author | Jeff Carr <[email protected]> | 2025-10-03 16:44:31 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-03 16:44:31 -0500 |
| commit | 2a04c33edf87e5396ceb3cc829622c16ce3c173a (patch) | |
| tree | dacdf64bd00e6c1d3242b50497320efac804aa5b /checkout.go | |
| parent | d9e303b50cbb11bb781c8173e028a89131c947ca (diff) | |
work around .gitignore changes causing dirty reposv0.0.142
Diffstat (limited to 'checkout.go')
| -rw-r--r-- | checkout.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/checkout.go b/checkout.go index 18253b7..6b6e819 100644 --- a/checkout.go +++ b/checkout.go @@ -8,6 +8,15 @@ import ( "go.wit.com/log" ) +func (repo *Repo) CheckoutMasterError() error { + bName := repo.GetMasterBranchName() + if err := repo.checkoutBranchError(bName); err != nil { + return err + } + return nil +} + +// deprecate this func (repo *Repo) CheckoutMaster() bool { bName := repo.GetMasterBranchName() if repo.checkoutBranch(bName) { @@ -16,6 +25,17 @@ func (repo *Repo) CheckoutMaster() bool { return false } +func (repo *Repo) CheckoutDevelError() error { + bName := repo.GetDevelBranchName() + if err := repo.checkoutBranchError(bName); err != nil { + return err + // switch ok + } + repo.DevelBranchName = bName + return nil +} + +// deprecate this func (repo *Repo) CheckoutDevel() bool { bName := repo.GetDevelBranchName() if repo.checkoutBranch(bName) { @@ -49,6 +69,38 @@ func (repo *Repo) BranchExists(bName string) bool { return true } +func (repo *Repo) checkoutBranchError(bName string) error { + if !repo.BranchExists(bName) { + return fmt.Errorf("no branch") + } + if bName == "" { + return fmt.Errorf("branch name was blank") + } + if repo.CheckDirty() { + log.Log(INFO, repo.GetFullPath(), "is dirty") + return fmt.Errorf("repo is dirty") + } + cmd := []string{"git", "checkout", bName} + r := repo.Run(cmd) + if r.Error != nil { + log.Log(INFO, "git checkout error:", r.Error) + return r.Error + } + + // remove this if everything works + realname := repo.GetCurrentBranchName() + realversion := repo.GetCurrentBranchVersion() + log.Info("checkoutranchError()", repo.GetFullPath(), "realname =", realname, "realversion =", realversion) + /* this is deprecated now probably + + if realname != bName { + log.Log(INFO, "git checkout failed", repo.GetFullPath(), bName, "!=", realname) + return fmt.Errorf("repo Reload() name match failure") + } + */ + return nil +} + func (repo *Repo) checkoutBranch(bName string) bool { if !repo.BranchExists(bName) { return false |
