general work on 'Build()'
This commit is contained in:
parent
7d4bb336b3
commit
10f53c5f17
2
Makefile
2
Makefile
|
@ -31,7 +31,7 @@ install-raw: goimports vet plugin
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
rm -f resources/*.so
|
rm -f resources/*.so
|
||||||
cp ../../toolkits/gocui/gocui.so resources/
|
-cp ../../toolkits/gocui/gocui.so resources/
|
||||||
|
|
||||||
andlabs: install
|
andlabs: install
|
||||||
forge --gui andlabs --debugger
|
forge --gui andlabs --debugger
|
||||||
|
|
2
argv.go
2
argv.go
|
@ -27,6 +27,8 @@ type args struct {
|
||||||
URL string `arg:"--connect" help:"forge url"`
|
URL string `arg:"--connect" help:"forge url"`
|
||||||
All bool `arg:"--all" help:"git commit --all"`
|
All bool `arg:"--all" help:"git commit --all"`
|
||||||
Show string `arg:"--show" help:"show a repo"`
|
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"`
|
Force bool `arg:"--force" help:"try to strong arm things"`
|
||||||
Verbose bool `arg:"--verbose" help:"show more output"`
|
Verbose bool `arg:"--verbose" help:"show more output"`
|
||||||
Bash bool `arg:"--bash" help:"generate bash completion"`
|
Bash bool `arg:"--bash" help:"generate bash completion"`
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
22
doClean.go
22
doClean.go
|
@ -290,7 +290,7 @@ func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error {
|
||||||
} else {
|
} else {
|
||||||
log.Info("why is this local only branch a problem?", branch.Name)
|
log.Info("why is this local only branch a problem?", branch.Name)
|
||||||
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
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 {
|
if err == nil {
|
||||||
cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]}
|
cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]}
|
||||||
repo.RunVerbose(cmd)
|
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)
|
log.Info("THIS USER BRANCH IS CLEAN TO DELETE", branch.Name)
|
||||||
if argv.Clean.Force != nil {
|
if argv.Clean.Force != nil {
|
||||||
cmd := []string{"git", "branch", "-D", branch.Name}
|
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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -397,20 +397,20 @@ func forceDeleteUserBranch(repo *gitpb.Repo, branch string) error {
|
||||||
configSave = true
|
configSave = true
|
||||||
|
|
||||||
cmd := []string{"git", "branch", "-D", branch}
|
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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch)
|
log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch)
|
||||||
if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) {
|
if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) {
|
||||||
cmd = []string{"git", "push", "origin", "--delete", 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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = []string{"git", "branch", "-D", "--remote", "origin/" + branch}
|
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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
|
@ -427,20 +427,20 @@ func BADforceDeleteBranch(repo *gitpb.Repo, branch string) error {
|
||||||
configSave = true
|
configSave = true
|
||||||
|
|
||||||
cmd := []string{"git", "branch", "-D", branch}
|
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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch)
|
log.Info("THIS USER REMOTE BRANCH MUST BE DELETED HERE", branch)
|
||||||
if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) {
|
if repo.Exists(filepath.Join(".git/refs/remote/origin", branch)) {
|
||||||
cmd = []string{"git", "push", "origin", "--delete", 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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = []string{"git", "branch", "-D", "--remote", "origin/" + branch}
|
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)
|
log.Info("THE GIT BRANCH DELETE ERROR IS:", err)
|
||||||
// return err
|
// return err
|
||||||
}
|
}
|
||||||
|
@ -513,12 +513,12 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {
|
||||||
if b1 == 0 {
|
if b1 == 0 {
|
||||||
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
||||||
log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd := []string{"git", "push"}
|
cmd := []string{"git", "push"}
|
||||||
log.Info("DEVEL LOCAL NEEDS GIT PUSH TO REMOTE", repo.GetGoPath(), cmd)
|
log.Info("DEVEL LOCAL NEEDS GIT PUSH TO REMOTE", repo.GetGoPath(), cmd)
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {
|
||||||
if b1 == 0 {
|
if b1 == 0 {
|
||||||
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
cmd := []string{"git", "branch", "-D", repo.GetDevelBranchName()}
|
||||||
log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
log.Info("DEVEL IS IN REMOTE", repo.GetGoPath(), cmd)
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd := []string{"git", "merge something somehow"}
|
cmd := []string{"git", "merge something somehow"}
|
||||||
|
|
16
doExamine.go
16
doExamine.go
|
@ -96,7 +96,7 @@ func examineBranch(repo *gitpb.Repo) error {
|
||||||
} else {
|
} else {
|
||||||
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
||||||
log.Info("why is this non-local branch a problem?", repo.CurrentTag.Refname)
|
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 {
|
if err == nil {
|
||||||
cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]}
|
cmd := []string{"git", "show", "-s", "--format=\"%H %ae %as %s\"", r.Stdout[0]}
|
||||||
repo.RunVerbose(cmd)
|
repo.RunVerbose(cmd)
|
||||||
|
@ -137,7 +137,7 @@ func examineBranch(repo *gitpb.Repo) error {
|
||||||
if argv.Clean.Examine.Fix == nil {
|
if argv.Clean.Examine.Fix == nil {
|
||||||
log.Info(repo.GetGoPath(), cmd)
|
log.Info(repo.GetGoPath(), cmd)
|
||||||
} else {
|
} else {
|
||||||
if _, err := repo.RunVerbose(cmd); err != nil {
|
if err := repo.RunVerbose(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ func examineBranch(repo *gitpb.Repo) error {
|
||||||
if argv.Clean.Examine.Fix == nil {
|
if argv.Clean.Examine.Fix == nil {
|
||||||
log.Info(repo.GetGoPath(), cmd)
|
log.Info(repo.GetGoPath(), cmd)
|
||||||
} else {
|
} else {
|
||||||
if _, err := repo.RunVerbose(cmd); err != nil {
|
if err := repo.RunVerbose(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ func examineBranch(repo *gitpb.Repo) error {
|
||||||
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
|
||||||
} else {
|
} else {
|
||||||
log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
|
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
|
return err
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -207,7 +207,7 @@ func showNotMaster(repo *gitpb.Repo) ([]string, error) {
|
||||||
cmd = append(cmd, repo.CurrentTag.Hash)
|
cmd = append(cmd, repo.CurrentTag.Hash)
|
||||||
cmd = append(cmd, "--not")
|
cmd = append(cmd, "--not")
|
||||||
cmd = append(cmd, repo.GetMasterBranchName())
|
cmd = append(cmd, repo.GetMasterBranchName())
|
||||||
r, err := repo.RunVerboseOnError(cmd)
|
r, err := repo.RunStrict(cmd)
|
||||||
return r.Stdout, err
|
return r.Stdout, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,14 +219,14 @@ func showNotDevel(repo *gitpb.Repo) ([]string, error) {
|
||||||
cmd = append(cmd, repo.CurrentTag.Hash)
|
cmd = append(cmd, repo.CurrentTag.Hash)
|
||||||
cmd = append(cmd, "--not")
|
cmd = append(cmd, "--not")
|
||||||
cmd = append(cmd, "devel")
|
cmd = append(cmd, "devel")
|
||||||
r, err := repo.RunVerboseOnError(cmd)
|
r, err := repo.RunStrict(cmd)
|
||||||
return r.Stdout, err
|
return r.Stdout, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// count all objects only in branch1
|
// count all objects only in branch1
|
||||||
func countDiffObjects(repo *gitpb.Repo, branch1, branch2 string) int {
|
func countDiffObjects(repo *gitpb.Repo, branch1, branch2 string) int {
|
||||||
cmd := repo.ConstructGitDiffLog(branch1, branch2)
|
cmd := repo.ConstructGitDiffLog(branch1, branch2)
|
||||||
r, err := repo.RunVerboseOnError(cmd)
|
r, err := repo.RunStrict(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func gitPushStrict(repo *gitpb.Repo, branchName string) error {
|
||||||
var cmd []string
|
var cmd []string
|
||||||
cmd = append(cmd, "git")
|
cmd = append(cmd, "git")
|
||||||
cmd = append(cmd, "push")
|
cmd = append(cmd, "push")
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd = []string{"git", "whatchanged", repo.CurrentTag.Hash, "-1"}
|
cmd = []string{"git", "whatchanged", repo.CurrentTag.Hash, "-1"}
|
||||||
repo.RunVerbose(cmd)
|
repo.RunVerbose(cmd)
|
||||||
|
|
|
@ -33,7 +33,7 @@ func rillPull(repo *gitpb.Repo) error {
|
||||||
|
|
||||||
var cmd []string
|
var cmd []string
|
||||||
cmd = append(cmd, "git", "pull")
|
cmd = append(cmd, "git", "pull")
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info(repo.GetFullPath(), "git pull err:", err)
|
log.Info(repo.GetFullPath(), "git pull err:", err)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func rillFetchMaster(repo *gitpb.Repo) error {
|
||||||
}
|
}
|
||||||
branch := repo.GetMasterBranchName()
|
branch := repo.GetMasterBranchName()
|
||||||
cmd := []string{"git", "fetch", "origin", branch + ":" + branch}
|
cmd := []string{"git", "fetch", "origin", branch + ":" + branch}
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
main.go
14
main.go
|
@ -85,6 +85,20 @@ func main() {
|
||||||
okExit("")
|
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 != nil {
|
||||||
if argv.Clean.Repo != "" {
|
if argv.Clean.Repo != "" {
|
||||||
log.Info("only looking at repo:", argv.Clean.Repo)
|
log.Info("only looking at repo:", argv.Clean.Repo)
|
||||||
|
|
|
@ -208,7 +208,7 @@ func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
|
||||||
|
|
||||||
func applyPatch(repo *gitpb.Repo, filename string) error {
|
func applyPatch(repo *gitpb.Repo, filename string) error {
|
||||||
cmd := []string{"git", "am", filename}
|
cmd := []string{"git", "am", filename}
|
||||||
_, err := repo.RunVerbose(cmd)
|
err := repo.RunVerbose(cmd)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue