troubleshooting branch names
This commit is contained in:
parent
659bed891b
commit
f459087158
2
Makefile
2
Makefile
|
@ -40,7 +40,7 @@ list: build
|
|||
reset
|
||||
./forge --list
|
||||
|
||||
list-real: build
|
||||
list-fix: build
|
||||
reset
|
||||
./forge --list --fix
|
||||
|
||||
|
|
2
argv.go
2
argv.go
|
@ -19,6 +19,8 @@ type args struct {
|
|||
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"`
|
||||
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 {
|
||||
|
|
28
list.go
28
list.go
|
@ -48,14 +48,17 @@ func verifyPrint(repo *gitpb.Repo) {
|
|||
me.forge.Repos.ConfigSave()
|
||||
} else {
|
||||
log.Info("need argv --real to delete", repo.GoPath)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
if me.forge.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
|
||||
return
|
||||
}
|
||||
start := fmt.Sprintf("%-40s %-8s %-10s %-10s %-10s %-10s", s["gopath"], s["rtype"], s["mver"], s["dver"], s["uver"], s["cver"])
|
||||
end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
|
||||
start := fmt.Sprintf("%-40s %-8s %-20s %-20s %-20s", s["gopath"], s["rtype"], s["cver"], s["mver"], s["cver"])
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -68,7 +71,7 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
|
|||
|
||||
s["mname"] = repo.GetMasterBranchName()
|
||||
if s["mname"] == "" {
|
||||
log.Info("verify() no master branch name")
|
||||
log.Info("verify() no master branch name", repo.GoPath)
|
||||
s["mver"] = repo.GetMasterVersion()
|
||||
return false
|
||||
}
|
||||
|
@ -80,20 +83,33 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
|
|||
|
||||
s["dname"] = repo.GetDevelBranchName()
|
||||
if s["dname"] == "" {
|
||||
log.Info("verify() no devel branch name")
|
||||
log.Info("verify() no devel branch name", repo.GoPath)
|
||||
return false
|
||||
}
|
||||
s["uname"] = repo.GetUserBranchName()
|
||||
if s["uname"] == "" {
|
||||
log.Info("verify() no user branch name")
|
||||
log.Info("verify() no user branch name", repo.GoPath)
|
||||
return false
|
||||
}
|
||||
s["cname"] = repo.GetCurrentBranchName()
|
||||
|
||||
s["mver"] = repo.GetMasterVersion()
|
||||
if s["mver"] == "" {
|
||||
log.Info("verify() no master branch name", repo.GoPath, repo.GetMasterBranchName())
|
||||
return false
|
||||
}
|
||||
s["dver"] = repo.GetDevelVersion()
|
||||
if s["dver"] == "" {
|
||||
log.Info("verify() no devel branch name", repo.GoPath, repo.GetDevelBranchName())
|
||||
return false
|
||||
}
|
||||
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["url"] = repo.URL
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -29,6 +29,7 @@ func main() {
|
|||
// may exit
|
||||
list()
|
||||
scan()
|
||||
repomap()
|
||||
os.Exit(0)
|
||||
|
||||
if argv.RedoGoMod {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue