troubleshooting branch names

This commit is contained in:
Jeff Carr 2024-12-03 01:56:58 -06:00
parent 659bed891b
commit f459087158
5 changed files with 97 additions and 20 deletions

View File

@ -40,7 +40,7 @@ list: build
reset reset
./forge --list ./forge --list
list-real: build list-fix: build
reset reset
./forge --list --fix ./forge --list --fix

26
argv.go
View File

@ -7,18 +7,20 @@ package main
var argv args var argv args
type args struct { type args struct {
List bool `arg:"--list" help:"list found repos"` List bool `arg:"--list" help:"list found repos"`
ListConf bool `arg:"--list-conf" help:"list your .config/forge/ configuration"` ListConf bool `arg:"--list-conf" help:"list your .config/forge/ configuration"`
Scan bool `arg:"--scan" help:"rescan your repos"` Scan bool `arg:"--scan" help:"rescan your repos"`
ReadOnly bool `arg:"--readonly" help:"include read-only repos"` ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
GetMine bool `arg:"--mine" help:"download private and writeable repos"` GetMine bool `arg:"--mine" help:"download private and writeable repos"`
GetFav bool `arg:"--favorites" help:"download repos marked as favorites"` GetFav bool `arg:"--favorites" help:"download repos marked as favorites"`
Pull bool `arg:"--git-pull" help:"run 'git pull' on all your repos"` Pull bool `arg:"--git-pull" help:"run 'git pull' on all your repos"`
Build bool `arg:"--build" default:"true" help:"also try to build it"` Build bool `arg:"--build" default:"true" help:"also try to build it"`
Install bool `arg:"--install" help:"try to install every binary package"` Install bool `arg:"--install" help:"try to install every binary package"`
RedoGoMod bool `arg:"--RedoGoMod" help:"remake all the go.sum and go.mod files"` RedoGoMod bool `arg:"--RedoGoMod" help:"remake all the go.sum and go.mod files"`
DryRun bool `arg:"--dry-run" help:"show what would be run"` DryRun bool `arg:"--dry-run" help:"show what would be run"`
Real bool `arg:"--fix" help:"fix config, save config & exit"` Real bool `arg:"--fix" help:"fix config, save config & exit"`
Repomap string `arg:"--repomap" help:"parse a repomap from gowebd"`
Clone bool `arg:"--clone" help:"go-clone things you are missing"`
} }
func (args) Version() string { func (args) Version() string {

30
list.go
View File

@ -48,14 +48,17 @@ func verifyPrint(repo *gitpb.Repo) {
me.forge.Repos.ConfigSave() me.forge.Repos.ConfigSave()
} else { } else {
log.Info("need argv --real to delete", repo.GoPath) log.Info("need argv --real to delete", repo.GoPath)
os.Exit(0)
} }
os.Exit(0)
} }
if me.forge.IsReadOnly(repo.GoPath) && ! argv.ReadOnly { if me.forge.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
return return
} }
start := fmt.Sprintf("%-40s %-8s %-10s %-10s %-10s %-10s", s["gopath"], s["rtype"], s["mver"], s["dver"], s["uver"], s["cver"]) start := fmt.Sprintf("%-40s %-8s %-20s %-20s %-20s", s["gopath"], s["rtype"], s["cver"], s["mver"], s["cver"])
end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"]) if s["url"] != "" {
end += "(" + s["url"] + ") "
}
// end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
log.Info(start, end) log.Info(start, end)
} }
@ -68,7 +71,7 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
s["mname"] = repo.GetMasterBranchName() s["mname"] = repo.GetMasterBranchName()
if s["mname"] == "" { if s["mname"] == "" {
log.Info("verify() no master branch name") log.Info("verify() no master branch name", repo.GoPath)
s["mver"] = repo.GetMasterVersion() s["mver"] = repo.GetMasterVersion()
return false return false
} }
@ -80,20 +83,33 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
s["dname"] = repo.GetDevelBranchName() s["dname"] = repo.GetDevelBranchName()
if s["dname"] == "" { if s["dname"] == "" {
log.Info("verify() no devel branch name") log.Info("verify() no devel branch name", repo.GoPath)
return false return false
} }
s["uname"] = repo.GetUserBranchName() s["uname"] = repo.GetUserBranchName()
if s["uname"] == "" { if s["uname"] == "" {
log.Info("verify() no user branch name") log.Info("verify() no user branch name", repo.GoPath)
return false return false
} }
s["cname"] = repo.GetCurrentBranchName() s["cname"] = repo.GetCurrentBranchName()
s["mver"] = repo.GetMasterVersion() s["mver"] = repo.GetMasterVersion()
if s["mver"] == "" {
log.Info("verify() no master branch name", repo.GoPath, repo.GetMasterBranchName())
return false
}
s["dver"] = repo.GetDevelVersion() s["dver"] = repo.GetDevelVersion()
if s["dver"] == "" {
log.Info("verify() no devel branch name", repo.GoPath, repo.GetDevelBranchName())
return false
}
s["uver"] = repo.GetUserVersion() s["uver"] = repo.GetUserVersion()
if s["uver"] == "" {
log.Info("verify() no user branch name", repo.GoPath, repo.GetUserBranchName())
return false
}
s["cver"] = repo.GetCurrentBranchVersion() s["cver"] = repo.GetCurrentBranchVersion()
s["url"] = repo.URL
return true return true
} }

View File

@ -29,6 +29,7 @@ func main() {
// may exit // may exit
list() list()
scan() scan()
repomap()
os.Exit(0) os.Exit(0)
if argv.RedoGoMod { if argv.RedoGoMod {

58
repomap.go Normal file
View File

@ -0,0 +1,58 @@
package main
import (
"os"
"strings"
"go.wit.com/log"
)
func repomap() {
var changed bool = false
if argv.Repomap == "" {
return
}
data, _ := os.ReadFile(argv.Repomap)
for _, line := range strings.Split(string(data), "\n") {
if line == "" {
continue
}
if strings.HasPrefix(line, "#") {
continue
}
parts := strings.Fields(line)
gopath := parts[0]
url := "https://" + parts[1]
var comment string
if len(parts) > 1 {
comment = strings.Join(parts[2:], " ")
}
repo := me.forge.Repos.FindByGoPath(gopath)
if repo == nil {
if argv.Clone {
me.forge.Clone(gopath)
} else {
log.Info(gopath, "need to clone")
}
} else {
if repo.URL != url {
log.Info(gopath, "url wrong", repo.URL, "vs", url)
log.Info("\tcomment", comment)
repo.URL = url
changed = true
}
if repo.Desc != comment && !(comment == "") {
log.Info(gopath, "comment wrong", repo.Desc, "vs", comment)
repo.Desc = comment
changed = true
}
}
}
if changed {
me.forge.Repos.ConfigSave()
log.Info("config saved")
os.Exit(0)
}
}