diff --git a/Makefile b/Makefile index 409f9d8..47b2a4b 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ install-raw: goimports vet plugin plugin: rm -f resources/*.so - cp ../../toolkits/gocui/gocui.so resources/ + -cp ../../toolkits/gocui/gocui.so resources/ andlabs: install forge --gui andlabs --debugger diff --git a/argv.go b/argv.go index 712a5c2..ae920f5 100644 --- a/argv.go +++ b/argv.go @@ -27,6 +27,8 @@ type args struct { URL string `arg:"--connect" help:"forge url"` All bool `arg:"--all" help:"git commit --all"` Show string `arg:"--show" help:"show a repo"` + Build string `arg:"--build" help:"build a repo"` + Install string `arg:"--install" help:"install a repo"` Force bool `arg:"--force" help:"try to strong arm things"` Verbose bool `arg:"--verbose" help:"show more output"` Bash bool `arg:"--bash" help:"generate bash completion"` diff --git a/doBuild.go b/doBuild.go new file mode 100644 index 0000000..112a529 --- /dev/null +++ b/doBuild.go @@ -0,0 +1,47 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + + "go.wit.com/log" +) + +func doBuild() error { + v := []string{} + if argv.Verbose { + v = []string{"-v", "-x"} + } + + gopath := argv.Build + + repo := me.forge.FindByGoPath(gopath) + if repo == nil { + return fmt.Errorf("rep not found: %s", gopath) + } + if err := me.forge.Build(repo, v); err != nil { + log.Warn("Build failed:", repo.GetGoPath(), err) + return err + } + return nil +} + +func doInstall() error { + v := []string{} + if argv.Verbose { + v = []string{"-v", "-x"} + } + + gopath := argv.Install + repo := me.forge.FindByGoPath(gopath) + if repo == nil { + return fmt.Errorf("rep not found: %s", gopath) + } + if err := me.forge.Install(repo, v); err != nil { + log.Warn("Install failed", repo.GetGoPath(), err) + return err + } + return nil +} diff --git a/doClean.go b/doClean.go index bf732de..bb6b134 100644 --- a/doClean.go +++ b/doClean.go @@ -290,7 +290,7 @@ func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error { } else { log.Info("why is this local only branch a problem?", branch.Name) repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) - r, err := repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/heads", branch.Name)}) + r, err := repo.RunStrict([]string{"cat", filepath.Join(".git/refs/heads", branch.Name)}) if err == nil { cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]} repo.RunVerbose(cmd) @@ -304,7 +304,7 @@ func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error { log.Info("THIS USER BRANCH IS CLEAN TO DELETE", branch.Name) if argv.Clean.Force != nil { cmd := []string{"git", "branch", "-D", branch.Name} - if _, err := repo.RunVerbose(cmd); err != nil { + if _, err := repo.RunStrict(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) return err } @@ -397,20 +397,20 @@ func forceDeleteUserBranch(repo *gitpb.Repo, branch string) error { configSave = true cmd := []string{"git", "branch", "-D", branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch) if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) { cmd = []string{"git", "push", "origin", "--delete", branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } } cmd = []string{"git", "branch", "-D", "--remote", "origin/" + branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } @@ -427,20 +427,20 @@ func BADforceDeleteBranch(repo *gitpb.Repo, branch string) error { configSave = true cmd := []string{"git", "branch", "-D", branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch) if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) { cmd = []string{"git", "push", "origin", "--delete", branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } } cmd = []string{"git", "branch", "-D", "--remote", "origin/" + branch} - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { log.Info("THE GIT BRANCH DELETE ERROR IS:", err) // return err } @@ -513,12 +513,12 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error { if b1 == 0 { cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()} log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd) - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) return err } cmd := []string{"git", "push"} log.Info("DEVEL LOCAL NEEDS GIT PUSH TO REMOTE", repo.GetGoPath(), cmd) - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) return err } @@ -528,7 +528,7 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error { if b1 == 0 { cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()} log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd) - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) return err } cmd := []string{"git", "merge something somehow"} diff --git a/doExamine.go b/doExamine.go index b4f99c4..45d0705 100644 --- a/doExamine.go +++ b/doExamine.go @@ -96,7 +96,7 @@ func examineBranch(repo *gitpb.Repo) error { } else { repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) log.Info("why is this non-local branch a problem?", repo.CurrentTag.Refname) - r, err := repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/remotes/origin", base)}) + r, err := repo.RunStrict([]string{"cat", filepath.Join(".git/refs/remotes/origin", base)}) if err == nil { cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]} repo.RunVerbose(cmd) @@ -137,7 +137,7 @@ func examineBranch(repo *gitpb.Repo) error { if argv.Clean.Examine.Fix == nil { log.Info(repo.GetGoPath(), cmd) } else { - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { return err } } @@ -145,7 +145,7 @@ func examineBranch(repo *gitpb.Repo) error { if argv.Clean.Examine.Fix == nil { log.Info(repo.GetGoPath(), cmd) } else { - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { return err } } @@ -156,7 +156,7 @@ func examineBranch(repo *gitpb.Repo) error { repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) } else { log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname) - if _, err := repo.RunVerbose(cmd); err != nil { + if err := repo.RunVerbose(cmd); err != nil { return err } else { return nil @@ -207,7 +207,7 @@ func showNotMaster(repo *gitpb.Repo) ([]string, error) { cmd = append(cmd, repo.CurrentTag.Hash) cmd = append(cmd, "--not") cmd = append(cmd, repo.GetMasterBranchName()) - r, err := repo.RunVerboseOnError(cmd) + r, err := repo.RunStrict(cmd) return r.Stdout, err } @@ -219,14 +219,14 @@ func showNotDevel(repo *gitpb.Repo) ([]string, error) { cmd = append(cmd, repo.CurrentTag.Hash) cmd = append(cmd, "--not") cmd = append(cmd, "devel") - r, err := repo.RunVerboseOnError(cmd) + r, err := repo.RunStrict(cmd) return r.Stdout, err } // count all objects only in branch1 func countDiffObjects(repo *gitpb.Repo, branch1, branch2 string) int { cmd := repo.ConstructGitDiffLog(branch1, branch2) - r, err := repo.RunVerboseOnError(cmd) + r, err := repo.RunStrict(cmd) if err != nil { return -1 } @@ -252,7 +252,7 @@ func gitPushStrict(repo *gitpb.Repo, branchName string) error { var cmd []string cmd = append(cmd, "git") cmd = append(cmd, "push") - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) if err != nil { cmd = []string{"git", "whatchanged", repo.CurrentTag.Hash, "-1"} repo.RunVerbose(cmd) diff --git a/doPull.go b/doPull.go index 0725ba3..edf3adf 100644 --- a/doPull.go +++ b/doPull.go @@ -33,7 +33,7 @@ func rillPull(repo *gitpb.Repo) error { var cmd []string cmd = append(cmd, "git", "pull") - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) if err != nil { log.Info(repo.GetFullPath(), "git pull err:", err) } @@ -89,7 +89,7 @@ func rillFetchMaster(repo *gitpb.Repo) error { } branch := repo.GetMasterBranchName() cmd := []string{"git", "fetch", "origin", branch + ":" + branch} - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) return err } diff --git a/main.go b/main.go index 0100a9d..82c4897 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,20 @@ func main() { okExit("") } + if argv.Build != "" { + if err := doBuild(); err != nil { + badExit(err) + } + okExit("") + } + + if argv.Install != "" { + if err := doInstall(); err != nil { + badExit(err) + } + okExit("") + } + if argv.Clean != nil { if argv.Clean.Repo != "" { log.Info("only looking at repo:", argv.Clean.Repo) diff --git a/windowPatchset.go b/windowPatchset.go index c24ec57..2ac5138 100644 --- a/windowPatchset.go +++ b/windowPatchset.go @@ -208,7 +208,7 @@ func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) { func applyPatch(repo *gitpb.Repo, filename string) error { cmd := []string{"git", "am", filename} - _, err := repo.RunVerbose(cmd) + err := repo.RunVerbose(cmd) return err }