can purge broken stuff
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9a57a20ef7
commit
10193b77f2
5
Makefile
5
Makefile
|
@ -40,6 +40,11 @@ list: build
|
|||
reset
|
||||
./forge --list
|
||||
|
||||
list-real: build
|
||||
reset
|
||||
./forge --list --real
|
||||
|
||||
|
||||
list-config: build
|
||||
./forge --list-conf
|
||||
|
||||
|
|
3
argv.go
3
argv.go
|
@ -15,8 +15,9 @@ type args struct {
|
|||
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:"--go-reset" 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"`
|
||||
Real bool `arg:"--real" help:"do the change, save config & exit"`
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
|
|
110
list.go
110
list.go
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -17,25 +18,24 @@ func list() {
|
|||
repos := me.forge.Repos.SortByGoPath()
|
||||
for repos.Scan() {
|
||||
repo := repos.Next()
|
||||
var rtype string
|
||||
if !repo.IsValid() {
|
||||
rtype = "rm?"
|
||||
continue
|
||||
} else {
|
||||
rtype = repo.RepoType()
|
||||
}
|
||||
if me.forge.IsReadOnly(repo.GetGoPath()) {
|
||||
continue
|
||||
}
|
||||
var end string
|
||||
if repo.CheckDirty() {
|
||||
end += "(dirty) "
|
||||
}
|
||||
mver := repo.GetMasterVersion()
|
||||
dver := repo.GetDevelVersion()
|
||||
uver := repo.GetUserVersion()
|
||||
s := fmt.Sprintf("%-50s %-8s %-10s %-10s %-10s", repo.GetGoPath(), rtype, mver, dver, uver)
|
||||
log.Info(s, end)
|
||||
s := make(map[string]string)
|
||||
if !verify(repo, s) {
|
||||
log.Info("going to delete", repo.GoPath)
|
||||
if argv.Real {
|
||||
me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
|
||||
me.forge.Repos.ConfigSave()
|
||||
} else {
|
||||
log.Info("need argv --real to delete", repo.GoPath)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
start := fmt.Sprintf("%-50s %-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"])
|
||||
log.Info(start, end)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
@ -50,3 +50,83 @@ func list() {
|
|||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
func whichOne(repo *gitpb.Repo, a map[string]any, hmm string) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateRepo(repo *gitpb.Repo, a map[string]any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func Delete(repo *gitpb.Repo, s map[string]string) bool {
|
||||
if repo.Published == nil {
|
||||
log.Info("published is nil", repo.Published)
|
||||
} else {
|
||||
log.Info("published len", repo.Published.Len())
|
||||
}
|
||||
|
||||
// add a new one here
|
||||
newr := gitpb.Repo{
|
||||
FullPath: repo.FullPath,
|
||||
GoPath: repo.GoPath,
|
||||
URL: repo.URL,
|
||||
Tags: repo.Tags,
|
||||
LastPull: repo.LastPull,
|
||||
MasterBranchName: repo.MasterBranchName,
|
||||
DevelBranchName: repo.DevelBranchName,
|
||||
UserBranchName: repo.UserBranchName,
|
||||
GoLibrary: repo.GoLibrary,
|
||||
GoBinary: repo.GoBinary,
|
||||
GoPrimitive: repo.GoPrimitive,
|
||||
GoPlugin: repo.GoPlugin,
|
||||
GoDeps: repo.GoDeps,
|
||||
LastGoDep: repo.LastGoDep,
|
||||
Dirty: repo.Dirty,
|
||||
Published: repo.Published,
|
||||
TargetVersion: repo.TargetVersion,
|
||||
ReadOnly: repo.ReadOnly,
|
||||
GoProtobuf: repo.GoProtobuf,
|
||||
}
|
||||
if argv.Real {
|
||||
me.forge.Repos.AppendUniqueGoPath(&newr)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func verify(repo *gitpb.Repo, s map[string]string) bool {
|
||||
if ! repo.IsValid() {
|
||||
return false
|
||||
}
|
||||
s["gopath"] = repo.GetGoPath()
|
||||
s["rtype"] = repo.RepoType()
|
||||
|
||||
s["mname"] = repo.GetMasterBranchName()
|
||||
if s["mname"] == "" {
|
||||
log.Info("verify() no master branch name")
|
||||
return false
|
||||
}
|
||||
// only verify the master branch name with read-only repos
|
||||
if me.forge.IsReadOnly(repo.GoPath) {
|
||||
return true
|
||||
}
|
||||
|
||||
s["dname"] = repo.GetDevelBranchName()
|
||||
if s["dname"] == "" {
|
||||
log.Info("verify() no devel branch name")
|
||||
return false
|
||||
}
|
||||
s["uname"] = repo.GetUserBranchName()
|
||||
if s["uname"] == "" {
|
||||
log.Info("verify() no user branch name")
|
||||
return false
|
||||
}
|
||||
s["cname"] = repo.GetCurrentBranchName()
|
||||
|
||||
s["mver"] = repo.GetMasterVersion()
|
||||
s["dver"] = repo.GetDevelVersion()
|
||||
s["uver"] = repo.GetUserVersion()
|
||||
s["cver"] = repo.GetCurrentBranchVersion()
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue