forgepb/gitCheckout.go

93 lines
2.1 KiB
Go

package forgepb
import (
"errors"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log"
)
func (f *Forge) GitPull() bool {
var localonly int
var badmap int
log.Log(FORGEPBWARN, "running git pull everywhere")
var failed int = 0
loop := f.Repos.SortByGoPath()
for loop.Scan() {
repo := loop.Next()
if out, err := repo.GitPull(); err == nil {
log.Log(FORGEPBWARN, "Ran git pull ok", repo.GetGoPath(), out)
} else {
failed += 1
// repo.DumpTags()
if errors.Is(repostatus.ErrorGitPullOnLocal, err) {
localonly += 1
continue
}
badmap += 1
log.Log(FORGEPBWARN, "bad unknown git error", repo.GetGoPath(), out, err)
}
}
log.Log(FORGEPBWARN, "Ran git pull in all repos. failure count =", failed)
log.Log(FORGEPBWARN, "Ran git pull in all repos. bad errors =", badmap)
if localonly != 0 {
log.Log(FORGEPBWARN, "Ran git pull in all repos. ignored local only branches =", localonly)
}
return true
}
func (f *Forge) CheckoutDevel() bool {
log.Log(FORGEPBWARN, "running git checkout devel everwhere")
var failed int = 0
var count int = 0
loop := f.Repos.SortByGoPath()
for loop.Scan() {
repo := loop.Next()
count += 1
if repo.CheckoutDevel() {
// checkout ok
} else {
failed += 1
}
}
log.Log(FORGEPBWARN, "Ran git checkout in", count, "repos. failure count =", failed)
return true
}
func (f *Forge) CheckoutMaster() bool {
log.Log(FORGEPBWARN, "running git checkout master everwhere")
var failed int = 0
var count int = 0
loop := f.Repos.SortByGoPath()
for loop.Scan() {
repo := loop.Next()
count += 1
if repo.CheckoutMaster() {
// checkout ok
} else {
failed += 1
}
}
log.Log(FORGEPBWARN, "Ran git checkout in", count, "repos. failure count =", failed)
return true
}
func (f *Forge) CheckoutUser() bool {
log.Log(FORGEPBWARN, "running git checkout master everwhere")
var failed int = 0
var count int = 0
loop := f.Repos.SortByGoPath()
for loop.Scan() {
repo := loop.Next()
count += 1
if repo.CheckoutUser() {
// checkout ok
} else {
failed += 1
}
}
log.Log(FORGEPBWARN, "Ran git checkout in", count, "repos. failure count =", failed)
return true
}