2024-01-09 01:16:00 -06:00
|
|
|
package main
|
|
|
|
|
2024-02-21 08:32:59 -06:00
|
|
|
// An app to submit patches for the 30 GO GUI repos
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-02-21 08:32:59 -06:00
|
|
|
import (
|
2024-12-14 13:12:42 -06:00
|
|
|
"strings"
|
2024-12-23 02:37:48 -06:00
|
|
|
"time"
|
2024-12-02 06:59:56 -06:00
|
|
|
|
|
|
|
"go.wit.com/dev/alexflint/arg"
|
2024-12-23 02:37:48 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-12-02 06:59:56 -06:00
|
|
|
"go.wit.com/lib/protobuf/forgepb"
|
2024-12-05 12:29:47 -06:00
|
|
|
"go.wit.com/lib/protobuf/gitpb"
|
2024-01-09 02:00:51 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
2024-12-02 06:59:56 -06:00
|
|
|
// sent via -ldflags
|
|
|
|
var VERSION string
|
|
|
|
var BUILDTIME string
|
|
|
|
|
2024-12-13 16:17:36 -06:00
|
|
|
// using this for now. triggers config save
|
|
|
|
var configSave bool
|
|
|
|
|
2024-12-17 06:36:00 -06:00
|
|
|
func getVersion(repo *gitpb.Repo, name string) string {
|
|
|
|
cmd := []string{"git", "describe", "--tags", "--always", name}
|
|
|
|
result := repo.RunQuiet(cmd)
|
|
|
|
output := strings.Join(result.Stdout, "\n")
|
|
|
|
log.Info("cmd =", cmd, output)
|
|
|
|
|
|
|
|
return strings.TrimSpace(output)
|
|
|
|
}
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
func main() {
|
2024-02-21 08:32:59 -06:00
|
|
|
me = new(mainType)
|
2024-12-02 06:59:56 -06:00
|
|
|
me.pp = arg.MustParse(&argv)
|
2024-12-14 13:12:42 -06:00
|
|
|
me.urlbase = argv.URL
|
|
|
|
me.urlbase = strings.Trim(me.urlbase, "/") // track down why trailing '/' makes http POST not work
|
2024-12-02 06:59:56 -06:00
|
|
|
|
|
|
|
// load the ~/.config/forge/ config
|
|
|
|
me.forge = forgepb.Init()
|
2024-12-05 12:29:47 -06:00
|
|
|
me.found = new(gitpb.Repos)
|
2024-01-18 05:03:04 -06:00
|
|
|
|
2024-12-17 06:36:00 -06:00
|
|
|
if configSave {
|
|
|
|
me.forge.ConfigSave()
|
|
|
|
configSave = false
|
|
|
|
}
|
|
|
|
|
2024-12-23 02:37:48 -06:00
|
|
|
if argv.User {
|
|
|
|
me.forge.CheckoutUser()
|
|
|
|
okExit("")
|
|
|
|
}
|
|
|
|
|
|
|
|
if argv.Master {
|
|
|
|
me.forge.CheckoutMaster()
|
|
|
|
okExit("")
|
|
|
|
}
|
|
|
|
|
2024-12-17 15:34:13 -06:00
|
|
|
if argv.Delete != "" {
|
|
|
|
me.forge.DeleteByGoPath(argv.Delete)
|
|
|
|
me.forge.SetConfigSave(true)
|
|
|
|
okExit("")
|
|
|
|
}
|
|
|
|
|
2024-12-18 22:02:07 -06:00
|
|
|
if argv.Dirty {
|
2024-12-23 02:37:48 -06:00
|
|
|
now := time.Now()
|
2024-12-18 22:02:07 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
doCobol()
|
2024-12-23 02:37:48 -06:00
|
|
|
log.Info("dirty check took:", shell.FormatDuration(time.Since(now)))
|
2024-12-18 22:02:07 -06:00
|
|
|
me.forge.SetConfigSave(configSave)
|
|
|
|
okExit("")
|
|
|
|
}
|
|
|
|
|
2024-12-17 06:36:00 -06:00
|
|
|
/*
|
|
|
|
// var count int
|
|
|
|
all := me.forge.Repos.SortByFullPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
|
|
|
verifyPrint(repo)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2024-12-17 01:14:37 -06:00
|
|
|
if argv.Fix {
|
|
|
|
okExit("")
|
|
|
|
}
|
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
// first find the repos or gopaths to operate on
|
|
|
|
if argv.Config {
|
|
|
|
if findConfig() {
|
|
|
|
me.forge.ConfigPrintTable()
|
2024-12-17 06:36:00 -06:00
|
|
|
okExit("")
|
2024-12-02 08:44:58 -06:00
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
} else {
|
|
|
|
findRepos()
|
2024-12-02 08:44:58 -06:00
|
|
|
}
|
2024-12-17 01:14:37 -06:00
|
|
|
// okExit("")
|
2024-02-12 15:24:35 -06:00
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
log.Info("found", me.found.Len(), "repos. found", len(me.foundPaths), "paths from .config/forge")
|
2024-02-12 15:24:35 -06:00
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
// now, do something to all of them (or just print out a table of them)
|
|
|
|
var done bool = false
|
|
|
|
if argv.DoScan {
|
|
|
|
doScan()
|
|
|
|
done = true
|
|
|
|
}
|
2024-02-14 13:43:43 -06:00
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
if argv.DoRedoGoMod {
|
|
|
|
doRedoGoMod()
|
|
|
|
done = true
|
|
|
|
}
|
2024-12-05 14:17:50 -06:00
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
if argv.DoGitPull {
|
|
|
|
doGitPull()
|
|
|
|
done = true
|
|
|
|
}
|
2024-12-05 14:17:50 -06:00
|
|
|
|
2024-12-13 17:13:07 -06:00
|
|
|
if argv.DoGitReset {
|
|
|
|
doGitReset()
|
|
|
|
done = true
|
|
|
|
}
|
|
|
|
|
2024-12-05 12:29:47 -06:00
|
|
|
if argv.DoList {
|
|
|
|
// print out the repos
|
|
|
|
doCobol()
|
|
|
|
done = true
|
|
|
|
}
|
2024-02-18 07:24:56 -06:00
|
|
|
|
2024-12-13 13:17:26 -06:00
|
|
|
if argv.DoPatchSet {
|
2024-12-11 22:48:52 -06:00
|
|
|
sendDevelDiff()
|
2024-12-13 13:17:26 -06:00
|
|
|
// sendMasterDiff()
|
2024-12-11 18:50:14 -06:00
|
|
|
okExit("patches")
|
2024-12-13 13:17:26 -06:00
|
|
|
}
|
|
|
|
|
2024-12-14 14:09:15 -06:00
|
|
|
if argv.ListPatchSet {
|
|
|
|
listPatches()
|
|
|
|
okExit("patches")
|
|
|
|
}
|
|
|
|
|
2024-12-13 13:17:26 -06:00
|
|
|
// do the gui at the very end
|
|
|
|
if argv.DoGui {
|
2024-12-05 12:29:47 -06:00
|
|
|
doGui()
|
|
|
|
}
|
|
|
|
if !done {
|
|
|
|
// if nothing was selected, print out a table of them on STDOUT
|
|
|
|
doCobol()
|
|
|
|
}
|
2024-12-17 06:36:00 -06:00
|
|
|
okExit("")
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|