2024-12-05 14:17:50 -06:00
|
|
|
package main
|
|
|
|
|
2024-12-06 01:48:17 -06:00
|
|
|
import (
|
2024-12-24 03:08:06 -06:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-12-06 01:48:17 -06:00
|
|
|
"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)
|
|
|
|
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.found.SortByFullPath()
|
2024-12-06 01:48:17 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
result := allerr[repo]
|
|
|
|
if result.Error == gitpb.ErrorGitPullOnDirty {
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("skip git pull. repo is dirty", repo.GetGoPath())
|
2024-12-06 01:48:17 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if result.Error == gitpb.ErrorGitPullOnLocal {
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("skip git pull. local branch ", repo.GetGoPath())
|
2024-12-06 01:48:17 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if result.Exit == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("git pull error:", repo.GetGoPath(), result.Error)
|
|
|
|
log.Info("git pull error:", repo.GetGoPath(), result.Stdout)
|
2024-12-06 01:48:17 -06:00
|
|
|
}
|
|
|
|
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
2024-12-24 03:08:06 -06:00
|
|
|
|
|
|
|
func doCheckDirty() {
|
|
|
|
now := time.Now()
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
dirty := repo.IsDirty()
|
|
|
|
if repo.CheckDirty() {
|
|
|
|
me.found.AppendUniqueGoPath(repo)
|
|
|
|
if !dirty {
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if dirty {
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-12-24 03:35:19 -06:00
|
|
|
// doCobol()
|
2024-12-24 03:08:06 -06:00
|
|
|
log.Info("dirty check took:", shell.FormatDuration(time.Since(now)))
|
|
|
|
me.forge.SetConfigSave(configSave)
|
|
|
|
}
|
|
|
|
|
2024-12-13 17:13:07 -06:00
|
|
|
func doGitReset() {
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.found.SortByFullPath()
|
2024-12-13 17:13:07 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
|
|
|
// log.Info("is readonly", repo.GetGoPath())
|
2024-12-13 17:13:07 -06:00
|
|
|
if repo.CheckDirty() {
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("is readonly and dirty", repo.GetGoPath())
|
2024-12-13 17:13:07 -06:00
|
|
|
cmd := []string{"git", "reset", "--hard"}
|
|
|
|
repo.RunRealtime(cmd)
|
|
|
|
}
|
|
|
|
} else {
|
2024-12-17 06:36:00 -06:00
|
|
|
// log.Info("is not readonly", repo.GetGoPath())
|
2024-12-13 17:13:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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 {
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("verify() no devel branch name", repo.GetGoPath())
|
2024-12-13 16:17:36 -06:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
if repo.GetUserBranchName() == "" {
|
|
|
|
if err := me.forge.MakeUserBranch(repo); err != nil {
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("verify() no devel branch name", repo.GetGoPath())
|
2024-12-13 16:17:36 -06:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
configSave = true
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|