summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'git.go')
-rw-r--r--git.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/git.go b/git.go
index 722a00c..c337fbb 100644
--- a/git.go
+++ b/git.go
@@ -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() {