2024-12-05 14:17:50 -06:00
|
|
|
package main
|
|
|
|
|
2024-12-06 01:48:17 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
2024-12-05 14:17:50 -06:00
|
|
|
|
|
|
|
func doScan() {
|
|
|
|
me.forge.ScanGoSrc()
|
|
|
|
}
|
|
|
|
|
|
|
|
func doGitPull() {
|
2024-12-06 01:48:17 -06:00
|
|
|
allerr := me.found.RillGitPull(40, 5)
|
|
|
|
|
|
|
|
all := me.found.SortByGoPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
result := allerr[repo]
|
|
|
|
if result.Error == gitpb.ErrorGitPullOnDirty {
|
|
|
|
log.Info("skip git pull. repo is dirty", repo.GoPath)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if result.Error == gitpb.ErrorGitPullOnLocal {
|
|
|
|
log.Info("skip git pull. local branch ", repo.GoPath)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if result.Exit == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info("git pull error:", repo.GoPath, result.Error)
|
|
|
|
log.Info("git pull error:", repo.GoPath, result.Stdout)
|
|
|
|
}
|
|
|
|
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func doFix() {
|
|
|
|
all := me.found.SortByGoPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
if !repo.IsValid() {
|
2024-12-13 13:17:26 -06:00
|
|
|
log.Printf("%10s %-50s", "old?\n", repo.GoPath)
|
|
|
|
me.forge.Repos.DeleteByGoPath(repo.GoPath)
|
2024-12-13 16:17:36 -06:00
|
|
|
configSave = true
|
2024-12-05 14:17:50 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Printf("running on: %-50s\n", repo.GetGoPath())
|
|
|
|
cmd := []string{"ls"}
|
|
|
|
repo.Run(cmd)
|
2024-12-13 16:17:36 -06:00
|
|
|
if err := checkoutBranches(repo); err != nil {
|
|
|
|
badExit(err)
|
|
|
|
}
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
2024-12-13 16:17:36 -06:00
|
|
|
if configSave {
|
2024-12-13 13:17:26 -06:00
|
|
|
me.forge.Repos.ConfigSave()
|
|
|
|
okExit("config saved")
|
|
|
|
}
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
2024-12-13 16:17:36 -06:00
|
|
|
|
|
|
|
func checkoutBranches(repo *gitpb.Repo) error {
|
|
|
|
dname := repo.GetDevelBranchName()
|
|
|
|
if dname == "" {
|
|
|
|
if err := me.forge.MakeDevelBranch(repo); err != nil {
|
|
|
|
log.Info("verify() no devel branch name", repo.GoPath)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
if repo.GetUserBranchName() == "" {
|
|
|
|
if err := me.forge.MakeUserBranch(repo); err != nil {
|
|
|
|
log.Info("verify() no devel branch name", repo.GoPath)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|