add git fetch
This commit is contained in:
parent
b354d7dd27
commit
9a1347c03f
34
merge.go
34
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()
|
||||
|
|
Loading…
Reference in New Issue