Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
8b199273e8 | |
|
67df8f90f9 | |
|
bb1df07910 | |
|
d19f4a8911 |
4
Makefile
4
Makefile
|
@ -1,7 +1,7 @@
|
||||||
VERSION = $(shell git describe --tags)
|
VERSION = $(shell git describe --tags)
|
||||||
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||||
|
|
||||||
run: install build-darwin build-darwin-arm64 build-windows
|
run: install
|
||||||
go-clone --version
|
go-clone --version
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
|
@ -51,7 +51,7 @@ nocui: build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
-rm go-clone
|
-rm go-clone*
|
||||||
go-mod-clean purge
|
go-mod-clean purge
|
||||||
|
|
||||||
# this will test the golang.org/x -> googlesource override
|
# this will test the golang.org/x -> googlesource override
|
||||||
|
|
20
argv.go
20
argv.go
|
@ -1,5 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this parses the command line arguements
|
this parses the command line arguements
|
||||||
|
|
||||||
|
@ -31,3 +36,18 @@ Examples:
|
||||||
go-clone go.wit.com/apps/go-clone # 'git clone' go-clone
|
go-clone go.wit.com/apps/go-clone # 'git clone' go-clone
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a args) DoAutoComplete(argv []string) {
|
||||||
|
switch argv[0] {
|
||||||
|
case "checkout":
|
||||||
|
fmt.Println("user devel master ")
|
||||||
|
case "--recursive":
|
||||||
|
fmt.Println("true false")
|
||||||
|
default:
|
||||||
|
if argv[0] == ARGNAME {
|
||||||
|
// list the subcommands here
|
||||||
|
fmt.Println("--dry-run --recursive --work")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
16
clone.go
16
clone.go
|
@ -68,7 +68,7 @@ func clone(gopath string) (*gitpb.Repo, error) {
|
||||||
gopath = CleanRepoURL(gopath)
|
gopath = CleanRepoURL(gopath)
|
||||||
os.Setenv("REPO_AUTO_CLONE", "true")
|
os.Setenv("REPO_AUTO_CLONE", "true")
|
||||||
// pb, _ := forge.NewGoPath(gopath)
|
// pb, _ := forge.NewGoPath(gopath)
|
||||||
check := forge.FindAnyPath(filepath.Join(forge.GetGoSrc(), gopath))
|
check := forge.FindAnyPath(filepath.Join(forge.Config.ReposDir, gopath))
|
||||||
if check != nil {
|
if check != nil {
|
||||||
if check.IsValidDir() {
|
if check.IsValidDir() {
|
||||||
// repo already exists and is valid
|
// repo already exists and is valid
|
||||||
|
@ -103,28 +103,28 @@ func recursiveClone(check *gitpb.Repo) error {
|
||||||
if check == nil {
|
if check == nil {
|
||||||
return errors.New("repo was nil")
|
return errors.New("repo was nil")
|
||||||
}
|
}
|
||||||
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
|
log.Info("STARTING RECURSIVE CLONE", check.Namespace)
|
||||||
log.Info("STARTING RECURSIVE CLONE", check.GetGoPath())
|
log.Info("STARTING RECURSIVE CLONE", check.Namespace)
|
||||||
// if just cloned, parse the go.sum file for deps
|
// if just cloned, parse the go.sum file for deps
|
||||||
if check.ParseGoSum() {
|
if check.ParseGoSum() {
|
||||||
} else {
|
} else {
|
||||||
makeValidGoSum(check)
|
makeValidGoSum(check)
|
||||||
}
|
}
|
||||||
|
|
||||||
check.Reload()
|
check.ReloadForce()
|
||||||
|
|
||||||
if check.GoDeps == nil {
|
if check.GoDeps == nil {
|
||||||
log.Info("repo godeps == nil", check.GetGoPath())
|
log.Info("repo godeps == nil", check.Namespace)
|
||||||
return errors.New("no go deps?")
|
return errors.New("no go deps?")
|
||||||
}
|
}
|
||||||
|
|
||||||
// probably this should never be 0 because GoPrimitive should have been true otherwise
|
// probably this should never be 0 because GoPrimitive should have been true otherwise
|
||||||
if check.GoDeps.Len() == 0 {
|
if check.GoDeps.Len() == 0 {
|
||||||
log.Info("repo len(godeps) == 0", check.GetGoPath())
|
log.Info("repo len(godeps) == 0", check.Namespace)
|
||||||
return errors.New("go.sum never parsed?")
|
return errors.New("go.sum never parsed?")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("deps for", check.GetGoPath(), "len()", check.GoDeps.Len())
|
log.Info("deps for", check.Namespace, "len()", check.GoDeps.Len())
|
||||||
deps := check.GoDeps.SortByGoPath()
|
deps := check.GoDeps.SortByGoPath()
|
||||||
for deps.Scan() {
|
for deps.Scan() {
|
||||||
depRepo := deps.Next()
|
depRepo := deps.Next()
|
||||||
|
@ -179,7 +179,7 @@ func makeValidGoSum(check *gitpb.Repo) error {
|
||||||
|
|
||||||
// if this fails, just use go mod
|
// if this fails, just use go mod
|
||||||
if err := check.ValidGoSum(); err != nil {
|
if err := check.ValidGoSum(); err != nil {
|
||||||
cmd := []string{"go", "mod", "init", check.GetGoPath()}
|
cmd := []string{"go", "mod", "init", check.Namespace}
|
||||||
log.Info("try running", cmd)
|
log.Info("try running", cmd)
|
||||||
if _, err := check.RunQuiet(cmd); err != nil {
|
if _, err := check.RunQuiet(cmd); err != nil {
|
||||||
log.Info("go mod init failed", err)
|
log.Info("go mod init failed", err)
|
||||||
|
|
19
main.go
19
main.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
|
"go.wit.com/lib/gui/prep"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -13,6 +14,8 @@ import (
|
||||||
var VERSION string
|
var VERSION string
|
||||||
var BUILDTIME string
|
var BUILDTIME string
|
||||||
|
|
||||||
|
var ARGNAME string = "go-clone"
|
||||||
|
|
||||||
var pp *arg.Parser
|
var pp *arg.Parser
|
||||||
var forge *forgepb.Forge
|
var forge *forgepb.Forge
|
||||||
|
|
||||||
|
@ -20,19 +23,11 @@ var workingRepo *gitpb.Repo
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Info("go-clone version", VERSION, "built on", BUILDTIME)
|
log.Info("go-clone version", VERSION, "built on", BUILDTIME)
|
||||||
|
// command line parsing & handling
|
||||||
|
prep.Bash(ARGNAME, argv.DoAutoComplete) // todo: make this: prep.Bash(argv)
|
||||||
|
|
||||||
pp = arg.MustParse(&argv)
|
pp = arg.MustParse(&argv)
|
||||||
|
|
||||||
// for very new users or users unfamilar with the command line, this may help them
|
|
||||||
if argv.Repo == "help" || argv.Repo == "?" {
|
|
||||||
pp.WriteHelp(os.Stdout)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
if argv.Repo == "version" {
|
|
||||||
log.Info(argv.Version())
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// this package helps scan git repos
|
|
||||||
forge = forgepb.Init()
|
forge = forgepb.Init()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -91,6 +86,6 @@ func okExit(thing string) {
|
||||||
|
|
||||||
func badExit(err error) {
|
func badExit(err error) {
|
||||||
log.Info("Total repositories:", forge.Repos.Len())
|
log.Info("Total repositories:", forge.Repos.Len())
|
||||||
log.Info("Finished go-clone with error", err, forge.GetGoSrc())
|
log.Info("Finished go-clone with error", err, forge.Config.ReposDir)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
6
work.go
6
work.go
|
@ -10,10 +10,10 @@ func autoWork() {
|
||||||
if !argv.AutoWork {
|
if !argv.AutoWork {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("About to re-create", forge.GetGoSrc()+"/go.work")
|
log.Info("About to re-create", forge.Config.ReposDir+"/go.work")
|
||||||
shell.PathRun(forge.GetGoSrc(), []string{"mv", "go.work", "go.work.last"})
|
shell.PathRun(forge.Config.ReposDir, []string{"mv", "go.work", "go.work.last"})
|
||||||
forge.MakeGoWork()
|
forge.MakeGoWork()
|
||||||
shell.PathRun(forge.GetGoSrc(), []string{"go", "work", "use"})
|
shell.PathRun(forge.Config.ReposDir, []string{"go", "work", "use"})
|
||||||
log.Info("")
|
log.Info("")
|
||||||
log.Info("original go.work file saved as go.work.last")
|
log.Info("original go.work file saved as go.work.last")
|
||||||
log.Info("")
|
log.Info("")
|
||||||
|
|
Loading…
Reference in New Issue