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