summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--merge.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/merge.go b/merge.go
index 48d99fd..8dcc716 100644
--- a/merge.go
+++ b/merge.go
@@ -1,6 +1,7 @@
package repostatus
import (
+ "errors"
"strconv"
"strings"
@@ -26,6 +27,39 @@ func (rs *RepoStatus) ResetBranches() bool {
return false
}
+func (rs *RepoStatus) FetchMaster() (error, string) {
+ // log.Log(REPOWARN, "FetchMaster() start", rs.Name())
+ master := rs.GetMasterBranchName()
+ return rs.fetchBranch(master)
+}
+
+func (rs *RepoStatus) FetchDevel() (error, string) {
+ devel := rs.GetDevelBranchName()
+ return rs.fetchBranch(devel)
+}
+
+// fetch the branch 'apple'
+func (rs *RepoStatus) fetchBranch(apple string) (error, string) {
+ if rs.GetCurrentBranchName() != rs.GetUserBranchName() {
+ return errors.New("not in user branch"), ""
+ }
+ if rs.gitConfig == nil {
+ return errors.New("missing .git/config"), ""
+ }
+ log.Log(REPOWARN, rs.Name(), "looking for branch:", apple)
+ for name, branch := range rs.gitConfig.branches {
+ if name == apple {
+ // found the branch!
+ log.Log(REPOWARN, " ", name, "remote:", branch.remote, "merge", branch.merge)
+ cmd := []string{"git", "fetch", branch.remote, apple + ":" + apple}
+ log.Log(REPOWARN, "running:", rs.Name(), cmd)
+ err, out := rs.RunCmd(cmd)
+ return err, out
+ }
+ }
+ return errors.New("branch " + apple + " not found"), ""
+}
+
func (rs *RepoStatus) MergeUserToDevel() bool {
startbranch := rs.GetCurrentBranchName()
devel := rs.GetDevelBranchName()