look for out of date remote branches
This commit is contained in:
parent
7d60a495ca
commit
33c585f4cf
18
reload.go
18
reload.go
|
@ -54,12 +54,30 @@ func (repo *Repo) Reload() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repo.VerifyRemoteAndLocalBranches(repo.GetDevelBranchName())
|
||||||
|
repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName())
|
||||||
|
|
||||||
// LastUpdate should always be the newest time
|
// LastUpdate should always be the newest time
|
||||||
repo.Times.LastUpdate = timestamppb.New(time.Now())
|
repo.Times.LastUpdate = timestamppb.New(time.Now())
|
||||||
repo.ValidateUTF8()
|
repo.ValidateUTF8()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repo) VerifyRemoteAndLocalBranches(bname string) bool {
|
||||||
|
if !repo.IsBranchRemote(bname) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
lh := repo.GetLocalHash(bname)
|
||||||
|
rh := repo.GetRemoteHash(bname)
|
||||||
|
if lh == rh {
|
||||||
|
// log.Info(r.FullPath, "local devel == remote devel", lh, rh)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
log.Info(repo.FullPath, bname, "local != remote", lh, rh)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repo) SetDevelBranchName(bname string) {
|
func (repo *Repo) SetDevelBranchName(bname string) {
|
||||||
repo.DevelBranchName = bname
|
repo.DevelBranchName = bname
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,15 @@ func (r *Repo) MergeToMaster() (*cmd.Status, error) {
|
||||||
if r.GetReadOnly() {
|
if r.GetReadOnly() {
|
||||||
r.Reload() // rescan the repo
|
r.Reload() // rescan the repo
|
||||||
// master branch is read only. you can not git push
|
// master branch is read only. you can not git push
|
||||||
return nil, fmt.Errorf("can't merge to master on read only() repos")
|
lh := r.GetLocalHash("devel")
|
||||||
|
rh := r.GetRemoteHash("devel")
|
||||||
|
if lh == rh {
|
||||||
|
// log.Info(r.FullPath, "local devel == remote devel", lh, rh)
|
||||||
|
} else {
|
||||||
|
log.Info(r.FullPath, "local devel != remote devel", lh, rh)
|
||||||
|
}
|
||||||
|
log.Info("can't merge to master on read only() repos. trying anyway")
|
||||||
|
// return nil, fmt.Errorf("can't merge to master on read only() repos")
|
||||||
}
|
}
|
||||||
if r.CheckDirty() {
|
if r.CheckDirty() {
|
||||||
return nil, fmt.Errorf("repo is dirty")
|
return nil, fmt.Errorf("repo is dirty")
|
||||||
|
|
Loading…
Reference in New Issue