summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--argv.go26
-rw-r--r--list.go30
-rw-r--r--main.go1
-rw-r--r--repomap.go58
5 files changed, 97 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 53e694b..007eee0 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ list: build
reset
./forge --list
-list-real: build
+list-fix: build
reset
./forge --list --fix
diff --git a/argv.go b/argv.go
index 8fe0b64..9f79d48 100644
--- a/argv.go
+++ b/argv.go
@@ -7,18 +7,20 @@ package main
var argv args
type args struct {
- List bool `arg:"--list" help:"list found repos"`
- ListConf bool `arg:"--list-conf" help:"list your .config/forge/ configuration"`
- Scan bool `arg:"--scan" help:"rescan your repos"`
- ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
- GetMine bool `arg:"--mine" help:"download private and writeable repos"`
- GetFav bool `arg:"--favorites" help:"download repos marked as favorites"`
- 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"`
- 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"`
- DryRun bool `arg:"--dry-run" help:"show what would be run"`
- Real bool `arg:"--fix" help:"fix config, save config & exit"`
+ List bool `arg:"--list" help:"list found repos"`
+ ListConf bool `arg:"--list-conf" help:"list your .config/forge/ configuration"`
+ Scan bool `arg:"--scan" help:"rescan your repos"`
+ ReadOnly bool `arg:"--readonly" help:"include read-only repos"`
+ GetMine bool `arg:"--mine" help:"download private and writeable repos"`
+ GetFav bool `arg:"--favorites" help:"download repos marked as favorites"`
+ 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"`
+ 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"`
+ 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 {
diff --git a/list.go b/list.go
index e9f9476..4e4cca4 100644
--- a/list.go
+++ b/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)
}
- os.Exit(0)
}
- if me.forge.IsReadOnly(repo.GoPath) && ! argv.ReadOnly {
+ 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
}
diff --git a/main.go b/main.go
index e7dc710..7b0bef8 100644
--- a/main.go
+++ b/main.go
@@ -29,6 +29,7 @@ func main() {
// may exit
list()
scan()
+ repomap()
os.Exit(0)
if argv.RedoGoMod {
diff --git a/repomap.go b/repomap.go
new file mode 100644
index 0000000..cfedd19
--- /dev/null
+++ b/repomap.go
@@ -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)
+ }
+}