allow switching all branches

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-31 00:19:39 -06:00
parent 1fda646fef
commit fae78b1812
1 changed files with 26 additions and 0 deletions

26
git.go
View File

@ -126,6 +126,7 @@ func (rs *RepoStatus) CheckDirty() bool {
}
/*
func (rs *RepoStatus) CheckoutBranch(branch string) (string, string) {
// run(rs.realPath.String(), "git", "checkout " + branch)
@ -134,6 +135,31 @@ func (rs *RepoStatus) CheckoutBranch(branch string) (string, string) {
log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
return realname, realversion
}
*/
func (rs *RepoStatus) CheckoutMaster() bool {
if rs.CheckDirty() {
log.Log(INFO, rs.realPath.String(), "is dirty")
return false
}
mName := rs.GetMasterBranchName()
cmd := []string{"git", "checkout", mName}
err, b, output := RunCmd(rs.realPath.String(), cmd)
if err != nil {
log.Log(INFO, err, b, output)
}
realname := rs.getCurrentBranchName()
realversion := rs.getCurrentBranchVersion()
log.Log(INFO, rs.realPath.String(), "realname =", realname, "realversion =", realversion)
if realname != mName {
log.Log(INFO, "git checkout failed", rs.realPath.String(), mName, "!=", realname)
return false
}
rs.masterBranchVersion.SetValue(realversion)
return true
}
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
if rs.CheckDirty() {