general improvements
This commit is contained in:
parent
923160d70c
commit
0463030e80
44
Makefile
44
Makefile
|
@ -1,17 +1,13 @@
|
|||
VERSION = $(shell git describe --tags)
|
||||
BUILDTIME = $(shell date +%Y.%m.%d)
|
||||
|
||||
all: vet build
|
||||
./forge -h
|
||||
all: goimports vet install
|
||||
forge -h
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
@echo this go binary package builds okay
|
||||
|
||||
build:
|
||||
GO111MODULE=off go build \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
verbose:
|
||||
GO111MODULE=off go build -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
@ -25,8 +21,8 @@ goimports:
|
|||
@# // to globally reset paths:
|
||||
@# // gofmt -w -r '"go.wit.com/gui/gadgets" -> "go.wit.com/lib/gadgets"' *.go
|
||||
|
||||
gocui: build
|
||||
./forge --gui gocui
|
||||
gocui: install
|
||||
forge --gui gocui
|
||||
|
||||
check-git-clean:
|
||||
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
|
||||
|
@ -37,34 +33,34 @@ redomod:
|
|||
GO111MODULE= go mod tidy
|
||||
|
||||
redomod-all:
|
||||
./forge --RedoGoMod
|
||||
forge --RedoGoMod
|
||||
|
||||
redomod-erase:
|
||||
./forge --RedoGoMod --erase
|
||||
forge --RedoGoMod --erase
|
||||
|
||||
list: build
|
||||
list: install
|
||||
reset
|
||||
./forge --list
|
||||
forge --list
|
||||
|
||||
list-private: build
|
||||
list-private: install
|
||||
reset
|
||||
./forge --list --private
|
||||
forge --list --private
|
||||
|
||||
list-fix: build
|
||||
list-fix: install
|
||||
reset
|
||||
./forge --list --fix
|
||||
forge --list --fix
|
||||
|
||||
list-readonly: build
|
||||
list-readonly: install
|
||||
reset
|
||||
./forge --list --readonly
|
||||
forge --list --readonly
|
||||
|
||||
list-config: build
|
||||
./forge --list-conf
|
||||
list-config: install
|
||||
forge --list-conf
|
||||
|
||||
scan: build
|
||||
scan: install
|
||||
reset
|
||||
./forge --scan
|
||||
forge --scan
|
||||
|
||||
|
||||
mine: build
|
||||
./forge --mine
|
||||
mine: install
|
||||
forge --mine
|
||||
|
|
33
argv.go
33
argv.go
|
@ -7,23 +7,22 @@ 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"`
|
||||
Repomap string `arg:"--repomap" help:"parse a repomap from gowebd"`
|
||||
Clone bool `arg:"--clone" help:"go-clone things you are missing"`
|
||||
Force bool `arg:"--force" help:"force redo go-clone"`
|
||||
Erase bool `arg:"--erase" help:"erase"`
|
||||
Private bool `arg:"--private" help:"list private repos in .config/forge/"`
|
||||
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"`
|
||||
Mine bool `arg:"--mine" help:"download private and writeable repos"`
|
||||
Favorites bool `arg:"--favorites" help:"download repos marked as favorites"`
|
||||
GitPull 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"`
|
||||
Fix bool `arg:"--fix" help:"fix config, save config & exit"`
|
||||
Clone bool `arg:"--clone" help:"go-clone things you are missing"`
|
||||
Force bool `arg:"--force" help:"force redo go-clone"`
|
||||
Erase bool `arg:"--erase" help:"erase"`
|
||||
Private bool `arg:"--private" help:"list private repos in .config/forge/"`
|
||||
}
|
||||
|
||||
func (args) Version() string {
|
||||
|
|
|
@ -34,7 +34,7 @@ func Delete(repo *gitpb.Repo, s map[string]string) bool {
|
|||
ReadOnly: repo.ReadOnly,
|
||||
GoProtobuf: repo.GoProtobuf,
|
||||
}
|
||||
if argv.Real {
|
||||
if argv.Fix {
|
||||
me.forge.Repos.AppendUniqueGoPath(&newr)
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -5,11 +5,10 @@ import (
|
|||
"os/user"
|
||||
"path/filepath"
|
||||
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func doesExist(path string) bool {
|
||||
|
|
|
@ -7,23 +7,25 @@ import (
|
|||
)
|
||||
|
||||
func hideFunction(r *repolist.RepoRow) {
|
||||
if r.Status.IsDirty() {
|
||||
/*
|
||||
if r.Status.IsDirty() {
|
||||
r.Show()
|
||||
return
|
||||
}
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if r.Status.ReadOnly() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if r.IsPerfect() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
r.Show()
|
||||
return
|
||||
}
|
||||
if me.autoHideReadOnly.Checked() {
|
||||
if r.Status.ReadOnly() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
if me.autoHidePerfect.Checked() {
|
||||
if r.IsPerfect() {
|
||||
r.Hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
r.Show()
|
||||
*/
|
||||
}
|
||||
|
||||
func globalDisplayOptions(vbox *gui.Node) {
|
||||
|
|
98
list.go
98
list.go
|
@ -10,34 +10,25 @@ import (
|
|||
|
||||
func list() {
|
||||
log.DaemonMode(true)
|
||||
if argv.ListConf {
|
||||
me.forge.ConfigPrintTable()
|
||||
os.Exit(0)
|
||||
if argv.Private {
|
||||
// GetPrivate()
|
||||
return
|
||||
}
|
||||
|
||||
if argv.Private {
|
||||
if argv.Mine {
|
||||
log.Printf("get mine %s\n", me.forge.GetGoSrc())
|
||||
repos := me.forge.Repos.SortByGoPath()
|
||||
for repos.Scan() {
|
||||
repo := repos.Next()
|
||||
if me.forge.IsPrivate(repo.GoPath) {
|
||||
if me.forge.Config.IsWritable(repo.GoPath) {
|
||||
verifyPrint(repo)
|
||||
}
|
||||
}
|
||||
configs := me.forge.Config.SortByGoPath()
|
||||
for configs.Scan() {
|
||||
thing := configs.Next()
|
||||
if thing.Directory {
|
||||
continue
|
||||
}
|
||||
if thing.Private {
|
||||
found := me.forge.Repos.FindByGoPath(thing.GoPath)
|
||||
if found == nil {
|
||||
log.Info("have not downloaded private:", thing.GoPath)
|
||||
} else {
|
||||
log.Info("already downloaded private:", thing.GoPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if argv.Favorites {
|
||||
log.Printf("get favorites\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
@ -46,7 +37,7 @@ func list() {
|
|||
repos := me.forge.Repos.SortByGoPath()
|
||||
for repos.Scan() {
|
||||
repo := repos.Next()
|
||||
if me.forge.IsReadOnly(repo) && !argv.ReadOnly {
|
||||
if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
|
||||
if repo.ReadOnly {
|
||||
continue
|
||||
}
|
||||
|
@ -63,16 +54,6 @@ func list() {
|
|||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if argv.GetMine {
|
||||
log.Printf("get mine %s", me.forge.GetGoSrc())
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if argv.GetFav {
|
||||
log.Printf("get favorites")
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
func verifyPrint(repo *gitpb.Repo) {
|
||||
|
@ -83,7 +64,7 @@ func verifyPrint(repo *gitpb.Repo) {
|
|||
s := make(map[string]string)
|
||||
if !verify(repo, s) {
|
||||
log.Info("going to delete", repo.GoPath)
|
||||
if argv.Real {
|
||||
if argv.Fix {
|
||||
me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
|
||||
me.forge.Repos.ConfigSave()
|
||||
} else {
|
||||
|
@ -91,21 +72,32 @@ func verifyPrint(repo *gitpb.Repo) {
|
|||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
if me.forge.IsReadOnly(repo) && !argv.ReadOnly {
|
||||
if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
|
||||
if repo.ReadOnly {
|
||||
return
|
||||
}
|
||||
log.Info("readonly flag on repo is wrong", repo.GoPath)
|
||||
return
|
||||
}
|
||||
start := fmt.Sprintf("%-40s %-8s %-20s %-20s %-20s", s["gopath"], s["rtype"], s["cver"], s["mver"], s["cver"])
|
||||
//if s["url"] != "" {
|
||||
// end += "(" + s["url"] + ") "
|
||||
//}
|
||||
if repo.ReadOnly {
|
||||
slen := 12
|
||||
var chort string = s["cver"]
|
||||
var mhort string = s["mver"]
|
||||
var uhort string = s["uver"]
|
||||
if len(s["cver"]) > slen {
|
||||
chort = s["cver"][:slen]
|
||||
}
|
||||
if len(s["mver"]) > slen {
|
||||
mhort = s["mver"][:slen]
|
||||
}
|
||||
if len(s["uver"]) > slen {
|
||||
uhort = s["uver"][:slen]
|
||||
}
|
||||
start := fmt.Sprintf("%-40s %-12s %-12s %-12s %-8s", s["gopath"], chort, mhort, uhort, s["rtype"])
|
||||
|
||||
if me.forge.Config.IsReadOnly(repo.GoPath) {
|
||||
end += "(readonly) "
|
||||
}
|
||||
// end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
|
||||
|
||||
log.Info(start, end)
|
||||
}
|
||||
|
||||
|
@ -123,7 +115,7 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
|
|||
return false
|
||||
}
|
||||
// only verify the master branch name with read-only repos
|
||||
if me.forge.IsReadOnly(repo) {
|
||||
if me.forge.Config.IsReadOnly(repo.GoPath) {
|
||||
s["mver"] = repo.GetMasterVersion()
|
||||
return true
|
||||
}
|
||||
|
@ -160,3 +152,29 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
func listPrivate() {
|
||||
repos := me.forge.Repos.SortByGoPath()
|
||||
for repos.Scan() {
|
||||
repo := repos.Next()
|
||||
if me.forge.Config.IsPrivate(repo.GoPath) {
|
||||
verifyPrint(repo)
|
||||
}
|
||||
}
|
||||
configs := me.forge.Config.SortByGoPath()
|
||||
for configs.Scan() {
|
||||
thing := configs.Next()
|
||||
if thing.Directory {
|
||||
continue
|
||||
}
|
||||
if thing.Private {
|
||||
found := me.forge.Repos.FindByGoPath(thing.GoPath)
|
||||
if found == nil {
|
||||
log.Info("have not downloaded private:", thing.GoPath)
|
||||
} else {
|
||||
log.Info("already downloaded private:", thing.GoPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
8
main.go
8
main.go
|
@ -25,11 +25,16 @@ func main() {
|
|||
me.forge = forgepb.Init()
|
||||
os.Setenv("REPO_WORK_PATH", me.forge.GetGoSrc())
|
||||
|
||||
// show your forge config settings
|
||||
if argv.ListConf {
|
||||
me.forge.ConfigPrintTable()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// processes any --list like options
|
||||
// may exit
|
||||
list()
|
||||
scan()
|
||||
repomap()
|
||||
|
||||
if argv.RedoGoMod {
|
||||
me.forge.RillRedoGoMod()
|
||||
|
@ -49,6 +54,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
me.pp.WriteHelp(os.Stdout)
|
||||
os.Exit(0)
|
||||
|
||||
me.myGui = gui.New()
|
||||
|
|
64
repomap.go
64
repomap.go
|
@ -1,64 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"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 argv.Force && argv.Clone {
|
||||
cmd := []string{"go-clone", "--recursive", gopath}
|
||||
shell.RunRealtime(cmd)
|
||||
continue
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import (
|
|||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/lib/protobuf/gitpb"
|
||||
)
|
||||
|
||||
var me *mainType
|
||||
|
@ -22,6 +23,7 @@ type mainType struct {
|
|||
pp *arg.Parser
|
||||
forge *forgepb.Forge
|
||||
myGui *gui.Node
|
||||
packs []*gitpb.Repo
|
||||
|
||||
// our view of the repositories
|
||||
repos *repoWindow
|
||||
|
|
Loading…
Reference in New Issue