refactor to use forgepb
This commit is contained in:
parent
fbab336c03
commit
6e5fbd4c33
53
main.go
53
main.go
|
@ -3,12 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gui/repolist"
|
"go.wit.com/lib/gui/repolist"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -30,16 +28,10 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// use ~/go/src unless we find a go.work file in a parent directory
|
// load the ~/.config/forge/ config
|
||||||
goSrcPath, err := forgepb.FindGoSrc()
|
forge := forgepb.Init()
|
||||||
if err != nil {
|
forge.ConfigPrintTable()
|
||||||
log.Info(err)
|
os.Setenv("REPO_WORK_PATH", forge.GetGoSrc())
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
if goSrcPath != "" {
|
|
||||||
os.Setenv("REPO_WORK_PATH", goSrcPath)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if argv.Repo == "" {
|
if argv.Repo == "" {
|
||||||
// if there isn't anything else, just exit here
|
// if there isn't anything else, just exit here
|
||||||
|
@ -76,18 +68,29 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets up gui stuff. not working yet
|
// testing gui idea
|
||||||
b := gui.RawBox()
|
myGui := gui.New()
|
||||||
rv = repolist.AutotypistView(b)
|
// myGui.Default()
|
||||||
|
|
||||||
|
rv := repolist.Init(forge, myGui)
|
||||||
|
rv.Enable()
|
||||||
|
|
||||||
|
rv.ScanRepositories()
|
||||||
|
|
||||||
// if the user defined a repo, attempt to download it now
|
// if the user defined a repo, attempt to download it now
|
||||||
if argv.Repo != "" {
|
if argv.Repo != "" {
|
||||||
os.Setenv("REPO_AUTO_CLONE", "true")
|
os.Setenv("REPO_AUTO_CLONE", "true")
|
||||||
newr, err := rv.NewRepo(argv.Repo)
|
// pb, _ := forge.NewGoPath(argv.Repo)
|
||||||
|
pb, err := forge.Clone(argv.Repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("could not download:", err)
|
log.Info("could not download:", err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
newr, err := rv.AddRepo(pb)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("AddRepo() failed", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
if argv.Recursive || argv.Pull || argv.RedoGoMod {
|
if argv.Recursive || argv.Pull || argv.RedoGoMod {
|
||||||
log.Info("repo already cloned", filepath.Join(goSrcPath, argv.Repo))
|
log.Info("repo already cloned", filepath.Join(goSrcPath, argv.Repo))
|
||||||
// there is more to do
|
// there is more to do
|
||||||
|
@ -115,7 +118,7 @@ func main() {
|
||||||
|
|
||||||
os.Setenv("REPO_AUTO_CLONE", "false")
|
os.Setenv("REPO_AUTO_CLONE", "false")
|
||||||
// look recursively in your working directory for git repos
|
// look recursively in your working directory for git repos
|
||||||
totalcount := scanForRepos(goSrcPath)
|
totalcount := forge.Repos.Len()
|
||||||
|
|
||||||
// if --git-pull, run git pull on everything here
|
// if --git-pull, run git pull on everything here
|
||||||
if argv.Pull {
|
if argv.Pull {
|
||||||
|
@ -153,7 +156,12 @@ func main() {
|
||||||
os.Setenv("REPO_AUTO_CLONE", "true")
|
os.Setenv("REPO_AUTO_CLONE", "true")
|
||||||
godep := newr.Status.GetGoDeps()
|
godep := newr.Status.GetGoDeps()
|
||||||
for gopath, version := range godep {
|
for gopath, version := range godep {
|
||||||
repo, err := rv.NewRepo(gopath)
|
pb, err := forge.Clone(gopath)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("could not download:", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
repo, err := rv.AddRepo(pb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("git clone failed for", gopath, version)
|
log.Info("git clone failed for", gopath, version)
|
||||||
continue
|
continue
|
||||||
|
@ -190,6 +198,7 @@ func main() {
|
||||||
log.Info("Finished go-clone for", argv.Repo)
|
log.Info("Finished go-clone for", argv.Repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func scanForRepos(goSrcPath string) int {
|
func scanForRepos(goSrcPath string) int {
|
||||||
var count int
|
var count int
|
||||||
log.Info("scanning for repo in:", filepath.Join(goSrcPath, argv.Repo))
|
log.Info("scanning for repo in:", filepath.Join(goSrcPath, argv.Repo))
|
||||||
|
@ -200,7 +209,13 @@ func scanForRepos(goSrcPath string) int {
|
||||||
gopath := strings.TrimPrefix(path, goSrcPath)
|
gopath := strings.TrimPrefix(path, goSrcPath)
|
||||||
gopath = strings.Trim(gopath, "/")
|
gopath = strings.Trim(gopath, "/")
|
||||||
// log.Info("Also should add:", gopath)
|
// log.Info("Also should add:", gopath)
|
||||||
rv.NewRepo(gopath)
|
pb, err := forge.Clone(gopath)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("could not download:", err)
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
repo, err := rv.AddRepo(pb)
|
||||||
}
|
}
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
/*
|
||||||
"bufio"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func addDir(d string) {
|
func addDir(d string) {
|
||||||
if shell.IsDir(d) {
|
if shell.IsDir(d) {
|
||||||
rv.NewRepo(d)
|
rv.NewRepo(d)
|
||||||
|
@ -47,3 +38,4 @@ func readControlFile(path string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue