Compare commits
38 Commits
Author | SHA1 | Date |
---|---|---|
|
e0520ca96d | |
|
6d7d74feb4 | |
|
9c87e1a040 | |
|
bda5fb4fbe | |
|
1e3f4a3b9f | |
|
e300719241 | |
|
a9c4b21b35 | |
|
37aebd9d73 | |
|
5a54f9c0b2 | |
|
31db2f96f6 | |
|
3a967eac13 | |
|
17a62eb8da | |
|
ba2f156c3d | |
|
3c922f1277 | |
|
ac16ef7127 | |
|
2ce32a0f2f | |
|
4d4dcf31cb | |
|
19479f312f | |
|
58ce9ca53c | |
|
62e8d457f1 | |
|
f936a17bc0 | |
|
9bc6d030e5 | |
|
b8252f5caa | |
|
ce0fd10064 | |
|
ae2cbf1886 | |
|
29f2084e25 | |
|
02d34d3e55 | |
|
e14f7b93d1 | |
|
7fdd7075fd | |
|
179c19147e | |
|
0aafe6bb86 | |
|
03b8e58451 | |
|
5637809f5c | |
|
86306aa887 | |
|
30ee1fcdf7 | |
|
9cdfface3c | |
|
c463ec70f0 | |
|
f4d60d1fb9 |
6
Makefile
6
Makefile
|
@ -6,8 +6,10 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||||
# make gocui # try the ncurses gui plugin
|
# make gocui # try the ncurses gui plugin
|
||||||
# make andlabs # try the andlabs gui plugin (uses GTK)
|
# make andlabs # try the andlabs gui plugin (uses GTK)
|
||||||
|
|
||||||
default: install-verbose
|
default: install-verbose tag
|
||||||
FORGE_VERBOSE=true forge list |head -n 20
|
|
||||||
|
tag:
|
||||||
|
forge tag list
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
|
|
@ -12,39 +12,6 @@ func savePatchset(pset *forgepb.Patchset) error {
|
||||||
log.Info("savePatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
|
log.Info("savePatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
|
||||||
log.Info("savePatches() Branch Name", pset.GetStartBranchName())
|
log.Info("savePatches() Branch Name", pset.GetStartBranchName())
|
||||||
log.Info("savePatches() Start Hash", pset.GetStartBranchHash())
|
log.Info("savePatches() Start Hash", pset.GetStartBranchHash())
|
||||||
|
|
||||||
var count int
|
|
||||||
var bad int
|
|
||||||
var lasterr error
|
|
||||||
all := pset.Patches.SortByFilename()
|
|
||||||
for all.Scan() {
|
|
||||||
p := all.Next()
|
|
||||||
basedir := filepath.Join(os.Getenv("FORGE_CONFIG"), "currentpatches")
|
|
||||||
if fullname, err := savePatchFile(p, basedir); err != nil {
|
|
||||||
log.Info(fullname, "save failed", err)
|
|
||||||
bad += 1
|
|
||||||
lasterr = err
|
|
||||||
}
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
log.Info("pset has", count, "total patches, ", bad, "bad save patches")
|
|
||||||
if bad == 0 {
|
|
||||||
return lasterr
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
// re-run git CheckDirty() on everything
|
|
||||||
func IsAnythingDirty() bool {
|
|
||||||
doCheckDirtyAndConfigSave()
|
|
||||||
found := me.forge.FindDirty()
|
|
||||||
if found.Len() == 0 {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -62,43 +29,6 @@ func countCurrentPatches(repo *gitpb.Repo) int {
|
||||||
return len(result.Stdout)
|
return len(result.Stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func savePatchFile(p *forgepb.Patch, basedir string) (string, error) {
|
|
||||||
basepath, filename := filepath.Split(p.Filename)
|
|
||||||
fulldir := filepath.Join(basedir, basepath)
|
|
||||||
err := os.MkdirAll(fulldir, os.ModePerm)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("applyPathces() MkdirAll failed for", fulldir)
|
|
||||||
log.Info("applyPathces() MkdirAll failed err", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
tmpname := filepath.Join(fulldir, filename)
|
|
||||||
log.Info("pset filename FILENAME IS REAL?", tmpname)
|
|
||||||
raw, _ := os.OpenFile(tmpname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
|
||||||
raw.Write(p.Data)
|
|
||||||
raw.Close()
|
|
||||||
return tmpname, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func readPatchFile(pbfile string) (*forgepb.Patchset, error) {
|
|
||||||
bytes, err := os.ReadFile(pbfile)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("readfile error", pbfile, err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return handleBytes(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleBytes(bytes []byte) (*forgepb.Patchset, error) {
|
|
||||||
var pset *forgepb.Patchset
|
|
||||||
pset = new(forgepb.Patchset)
|
|
||||||
err := pset.Unmarshal(bytes)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("Unmarshal failed", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return pset, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func doRegister(newurl string) error {
|
func doRegister(newurl string) error {
|
||||||
var url string
|
var url string
|
||||||
url = me.urlbase + "/register?url=" + newurl
|
url = me.urlbase + "/register?url=" + newurl
|
||||||
|
|
60
argv.go
60
argv.go
|
@ -6,6 +6,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"go.wit.com/lib/gui/prep"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -147,63 +149,49 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// handles shell autocomplete
|
// handles shell autocomplete
|
||||||
//
|
func DoAutoComplete(pb *prep.Auto) {
|
||||||
|
switch pb.Cmd {
|
||||||
func DoAutoComplete(argv []string) {
|
|
||||||
switch argv[0] {
|
|
||||||
case "checkout":
|
case "checkout":
|
||||||
fmt.Println("devel master user")
|
pb.Autocomplete2("devel master user")
|
||||||
case "clean":
|
case "clean":
|
||||||
// me.pp.WriteHelp(os.Stderr)
|
pb.Autocomplete2("")
|
||||||
// me.pp.WriteUsageForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
|
||||||
// me.pp.WriteHelpForSubcommand(os.Stderr, me.pp.SubcommandNames()...)
|
|
||||||
// me.pp.WriteHelpForSubcommand(os.Stderr, "clean")
|
|
||||||
fmt.Println("--force verify --repo")
|
|
||||||
case "commit":
|
case "commit":
|
||||||
fmt.Println("--all")
|
pb.Autocomplete2("--all")
|
||||||
case "config":
|
case "config":
|
||||||
fmt.Println("add fix list")
|
fmt.Println("add fix list")
|
||||||
case "dirty":
|
case "dirty":
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
case "gui":
|
case "gui":
|
||||||
if ifBlank(argv[1]) {
|
fmt.Println("")
|
||||||
fmt.Fprintln(os.Stderr, "")
|
case "--gui":
|
||||||
fmt.Fprintln(os.Stderr, "CUI: terminal interface using 'gocui'")
|
pb.Autocomplete2("andlabs gocui")
|
||||||
fmt.Fprintln(os.Stderr, "GUI: linux and macos GUI using GTK")
|
|
||||||
} else {
|
|
||||||
fmt.Println("CUI GUI")
|
|
||||||
}
|
|
||||||
case "list":
|
case "list":
|
||||||
fmt.Println("--mine --favorites --dirty")
|
pb.Autocomplete2("--mine --favorites --dirty")
|
||||||
case "merge":
|
case "merge":
|
||||||
fmt.Println("devel master")
|
pb.Autocomplete2("devel master --all")
|
||||||
case "normal":
|
case "normal":
|
||||||
fmt.Println("on off")
|
pb.Autocomplete2("on off")
|
||||||
case "pull":
|
case "pull":
|
||||||
fmt.Println("--force check")
|
pb.Autocomplete2("--force check")
|
||||||
case "patch":
|
case "patch":
|
||||||
fmt.Println("check get list repos submit show")
|
fmt.Println("check get list repos submit show")
|
||||||
case "user":
|
|
||||||
fmt.Println("--force")
|
|
||||||
case "devel":
|
|
||||||
fmt.Println("--force")
|
|
||||||
case "master":
|
|
||||||
fmt.Println("")
|
|
||||||
case "verify":
|
|
||||||
fmt.Println("user devel master")
|
|
||||||
case "tag":
|
case "tag":
|
||||||
fmt.Println("list --delete clean")
|
fmt.Println("list --delete clean")
|
||||||
default:
|
default:
|
||||||
if argv[0] == ARGNAME {
|
if pb.Cmd == "" {
|
||||||
// list the subcommands here
|
pb.Autocomplete2("help list checkout clean commit dirty fetch gui normal merge patch pull tag --gui")
|
||||||
fmt.Println("help list checkout clean commit dirty fetch gui normal merge patch pull tag")
|
} else {
|
||||||
|
pb.Autocomplete2("list checkout clean commit dirty normal merge tag")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (args) Appname() string {
|
||||||
|
return ARGNAME
|
||||||
|
}
|
||||||
|
|
||||||
func ifBlank(arg string) bool {
|
func ifBlank(arg string) bool {
|
||||||
if arg == "''" {
|
if arg == "''" {
|
||||||
// if empty, the user has not typed something
|
// if empty, the user has not typed something
|
||||||
|
@ -212,6 +200,6 @@ func ifBlank(arg string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a args) DoAutoComplete(argv []string) {
|
func (a args) DoAutoComplete(autoArgv *prep.Auto) {
|
||||||
DoAutoComplete(argv)
|
DoAutoComplete(autoArgv)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"go.wit.com/lib/config"
|
"go.wit.com/lib/config"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func forgeConfigSave() error {
|
func forgeConfigSave() error {
|
||||||
|
@ -18,6 +19,7 @@ func setForgeMode(fmode forgepb.ForgeMode) {
|
||||||
if me.forge.Config.Mode == fmode {
|
if me.forge.Config.Mode == fmode {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.Info("changing mode", me.forge.Config.Mode, fmode)
|
||||||
me.forge.Config.Mode = fmode
|
me.forge.Config.Mode = fmode
|
||||||
config.SetChanged("forge", true)
|
config.SetChanged("forge", true)
|
||||||
me.forge.Config.ConfigSave()
|
me.forge.Config.ConfigSave()
|
||||||
|
|
|
@ -27,6 +27,7 @@ func doCheckout() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout.Devel != nil {
|
if argv.Checkout.Devel != nil {
|
||||||
|
// setForgeMode(forgepb.ForgeMode_DEVEL)
|
||||||
if err := me.forge.DoAllCheckoutDevelNew(argv.Force); err != nil {
|
if err := me.forge.DoAllCheckoutDevelNew(argv.Force); err != nil {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ func justDeleteTheDevelBranchAlready(repo *gitpb.Repo) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cmd := []string{"git", "merge something somehow"}
|
cmd := []string{"git", "merge something somehow"}
|
||||||
log.Info("DEVEL LOCAL NEEDS GIT MERGE TO MASTER", repo.GetGoPath(), cmd, b1)
|
log.Info("devel local, remote and master branches are wrong", repo.GetGoPath(), cmd, b1)
|
||||||
// _, err := repo.RunVerbose(cmd)
|
// _, err := repo.RunVerbose(cmd)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,7 @@ func doCommit() error {
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
pwd, _ := os.Getwd()
|
repo := findCurrentPwdRepoOrDie()
|
||||||
repo := me.forge.Repos.FindByFullPath(pwd)
|
|
||||||
if repo == nil {
|
|
||||||
log.Info("todo: forge doesn't know how to work here yet")
|
|
||||||
okExit("")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !repo.CheckDirty() {
|
if !repo.CheckDirty() {
|
||||||
okExit(log.Sprintf("this repo %s is not dirty.\n\n--all # commit all changes in all repos", repo.GetFullPath()))
|
okExit(log.Sprintf("this repo %s is not dirty.\n\n--all # commit all changes in all repos", repo.GetFullPath()))
|
||||||
|
|
|
@ -55,7 +55,6 @@ func doConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("config.PathLock =", me.forge.Config.PathLock)
|
log.Info("config.PathLock =", me.forge.Config.PathLock)
|
||||||
log.Info("config.GoSrc =", me.forge.Config.GoSrc)
|
|
||||||
|
|
||||||
me.forge.ConfigPrintTable()
|
me.forge.ConfigPrintTable()
|
||||||
okExit("")
|
okExit("")
|
||||||
|
|
80
doMerge.go
80
doMerge.go
|
@ -4,11 +4,61 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/config"
|
||||||
|
"go.wit.com/lib/gui/shell"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func doMerge() error {
|
||||||
|
if argv.All == true {
|
||||||
|
start := time.Now()
|
||||||
|
repos, err := doMergeDevel()
|
||||||
|
dur := time.Since(start)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
log.Printf("Merged %d devel branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
||||||
|
|
||||||
|
start = time.Now()
|
||||||
|
repos, err = doMergeMaster()
|
||||||
|
dur = time.Since(start)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
log.Printf("Merged %d master branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
||||||
|
okExit("")
|
||||||
|
}
|
||||||
|
if argv.Merge.Devel != nil {
|
||||||
|
start := time.Now()
|
||||||
|
repos, err := doMergeDevel()
|
||||||
|
dur := time.Since(start)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
log.Printf("Merged %d devel branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
||||||
|
okExit("")
|
||||||
|
}
|
||||||
|
if argv.Merge.Master != nil {
|
||||||
|
start := time.Now()
|
||||||
|
repos, err := doMergeMaster()
|
||||||
|
dur := time.Since(start)
|
||||||
|
if err != nil {
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
log.Printf("Merged %d master branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
||||||
|
okExit("")
|
||||||
|
}
|
||||||
|
repo := findCurrentPwdRepoOrDie()
|
||||||
|
if err := repoMergeToDevel(repo); err != nil {
|
||||||
|
badRepoExit(repo, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func doMergeReport() *forgepb.Patches {
|
func doMergeReport() *forgepb.Patches {
|
||||||
found := forgepb.NewPatches()
|
found := forgepb.NewPatches()
|
||||||
for repo := range me.forge.Repos.IterAll() {
|
for repo := range me.forge.Repos.IterAll() {
|
||||||
|
@ -31,7 +81,7 @@ func doMergeDevel() (*gitpb.Repos, error) {
|
||||||
found := findMergeToDevel()
|
found := findMergeToDevel()
|
||||||
for repo := range found.IterAll() {
|
for repo := range found.IterAll() {
|
||||||
if repo.CheckDirty() {
|
if repo.CheckDirty() {
|
||||||
log.Info("repo is dirty", repo.GetGoPath())
|
log.Info("repo is dirty", repo.GetFullPath())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.Infof("%s starting git merge\n", repo.FullPath)
|
log.Infof("%s starting git merge\n", repo.FullPath)
|
||||||
|
@ -53,10 +103,37 @@ func doMergeDevel() (*gitpb.Repos, error) {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
done.Append(repo)
|
done.Append(repo)
|
||||||
|
config.SetChanged("repos", true)
|
||||||
}
|
}
|
||||||
return done, err
|
return done, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func repoMergeToDevel(repo *gitpb.Repo) error {
|
||||||
|
if repo.CheckDirty() {
|
||||||
|
return log.Errorf("can not merge. repo is dirty")
|
||||||
|
}
|
||||||
|
log.Infof("%s starting git merge\n", repo.FullPath)
|
||||||
|
if repo.CheckoutDevel() {
|
||||||
|
log.Info("checkout devel failed", repo.GetGoPath())
|
||||||
|
err := log.Errorf("checkout devel failed")
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
// hash differences when merging user into devel branch
|
||||||
|
out := repo.GetBranchDifferences(repo.GetDevelBranchName(), repo.GetUserBranchName())
|
||||||
|
for i, hash := range out {
|
||||||
|
log.Info("MERGE HASH FROM USER TO DEVEL", i, hash)
|
||||||
|
}
|
||||||
|
if _, err := repo.MergeToDevel(); err != nil {
|
||||||
|
log.Info("merge from user failed", repo.GetGoPath(), err)
|
||||||
|
// err := log.Errorf("merge from user failed")
|
||||||
|
// log.Info(strings.Join(r.Stdout, "\n"))
|
||||||
|
// log.Info(strings.Join(r.Stderr, "\n"))
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
config.SetChanged("repos", true)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func doMergeMaster() (*gitpb.Repos, error) {
|
func doMergeMaster() (*gitpb.Repos, error) {
|
||||||
var err error
|
var err error
|
||||||
setForgeMode(forgepb.ForgeMode_MASTER)
|
setForgeMode(forgepb.ForgeMode_MASTER)
|
||||||
|
@ -85,6 +162,7 @@ func doMergeMaster() (*gitpb.Repos, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
done.Append(repo)
|
done.Append(repo)
|
||||||
|
config.SetChanged("repos", true)
|
||||||
}
|
}
|
||||||
return done, err
|
return done, err
|
||||||
}
|
}
|
||||||
|
|
53
doNormal.go
53
doNormal.go
|
@ -6,8 +6,11 @@ package main
|
||||||
// checks that repos are in a "normal" state
|
// checks that repos are in a "normal" state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/lib/config"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -35,7 +38,7 @@ func doNormal() bool {
|
||||||
log.Info("Some repos are not in a 'normal' state. error count =", count)
|
log.Info("Some repos are not in a 'normal' state. error count =", count)
|
||||||
log.Info("TODO: list the repos here. forge patch repos?")
|
log.Info("TODO: list the repos here. forge patch repos?")
|
||||||
dumpWorkRepos()
|
dumpWorkRepos()
|
||||||
configSave = true
|
config.SetChanged("repos", true)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -47,19 +50,46 @@ func doNormal() bool {
|
||||||
// this needs to run each time in case repos were added manually by the user
|
// this needs to run each time in case repos were added manually by the user
|
||||||
// this also verifies that
|
// this also verifies that
|
||||||
func checkNormalRepoState(repo *gitpb.Repo) error {
|
func checkNormalRepoState(repo *gitpb.Repo) error {
|
||||||
|
var err error
|
||||||
|
tmp := filepath.Join(me.forge.Config.ReposDir, repo.GetNamespace())
|
||||||
|
if tmp != repo.FullPath {
|
||||||
|
log.Infof("%s != %s\n", repo.FullPath, tmp)
|
||||||
|
if strings.HasPrefix(repo.FullPath, me.forge.Config.ReposDir) {
|
||||||
|
tmp = strings.TrimPrefix(repo.FullPath, me.forge.Config.ReposDir)
|
||||||
|
tmp = strings.Trim(tmp, "/")
|
||||||
|
repo.Namespace = tmp
|
||||||
|
err = log.Errorf("namespace set to filepath")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// log.Infof("%s == %s\n", repo.FullPath, tmp)
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = strings.Trim(repo.Namespace, "/")
|
||||||
|
if tmp != repo.Namespace {
|
||||||
|
err = log.Errorf("junk in ns %s", repo.Namespace)
|
||||||
|
repo.Namespace = tmp
|
||||||
|
}
|
||||||
|
|
||||||
if repo.GetMasterBranchName() == "" {
|
if repo.GetMasterBranchName() == "" {
|
||||||
me.forge.VerifyBranchNames(repo)
|
me.forge.VerifyBranchNames(repo)
|
||||||
configSave = true
|
|
||||||
log.Info("ABNORMAL: master branch name was blank in", repo.GetFullPath())
|
log.Info("ABNORMAL: master branch name was blank in", repo.GetFullPath())
|
||||||
}
|
}
|
||||||
if repo.GetMasterBranchName() == "" {
|
if repo.GetMasterBranchName() == "" {
|
||||||
return log.Errorf("master branch name blank")
|
me.forge.VerifyBranchNames(repo)
|
||||||
|
err = log.Errorf("master branch name blank")
|
||||||
}
|
}
|
||||||
if repo.GetDevelBranchName() == "" {
|
if repo.GetDevelBranchName() == "" {
|
||||||
return log.Errorf("devel branch name blank")
|
me.forge.VerifyBranchNames(repo)
|
||||||
|
err = log.Errorf("devel branch name blank")
|
||||||
}
|
}
|
||||||
if repo.GetUserBranchName() == "" {
|
if repo.GetUserBranchName() == "" {
|
||||||
return log.Errorf("user branch name blank")
|
me.forge.VerifyBranchNames(repo)
|
||||||
|
err = log.Errorf("user branch name blank")
|
||||||
|
}
|
||||||
|
if repo.GetGoPath() == repo.GetNamespace() {
|
||||||
|
// log.Info(repo.FullPath, "gopath == namespace", repo.GetGoPath(), repo.GetNamespace())
|
||||||
|
} else {
|
||||||
|
log.Info(repo.FullPath, "gopath != namespace", repo.GetGoPath(), repo.GetNamespace())
|
||||||
}
|
}
|
||||||
repo.MakeLocalDevelBranch()
|
repo.MakeLocalDevelBranch()
|
||||||
|
|
||||||
|
@ -67,11 +97,16 @@ func checkNormalRepoState(repo *gitpb.Repo) error {
|
||||||
repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName())
|
repo.VerifyRemoteAndLocalBranches(repo.GetMasterBranchName())
|
||||||
|
|
||||||
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
|
if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
|
||||||
configSave = true
|
log.Infof("changing to user(%s) branch: %s\n", repo.GetUserBranchName(), repo.FullPath)
|
||||||
log.Info("changing to user branch", repo.FullPath)
|
|
||||||
repo.CheckoutUser()
|
repo.CheckoutUser()
|
||||||
repo.ReloadCheck()
|
repo.ReloadCheck()
|
||||||
return log.Errorf("now on user branch")
|
err = log.Errorf("now on user branch")
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) != repo.GetReadOnly() {
|
||||||
|
repo.ReadOnly = me.forge.Config.IsReadOnly(repo.GetGoPath())
|
||||||
|
log.Info("damnit", repo.FullPath)
|
||||||
|
err = log.Errorf("readonly bit wrong")
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
69
doPatch.go
69
doPatch.go
|
@ -45,7 +45,16 @@ func doPatchSubmit() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, _, err = pset.Patches.HttpPostVerbose(myServer(), "new")
|
if pset.Patches == nil {
|
||||||
|
log.Info("pset.Patches == nil")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if pset.Patches.Len() == 0 {
|
||||||
|
log.Info("did not find any patches")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
pset.PrintTable()
|
||||||
|
_, _, err = pset.HttpPost(myServer(), "new")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +73,7 @@ func doPatch() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Patch.Get != nil {
|
if argv.Patch.Get != nil {
|
||||||
psets := forgepb.NewPatchsets()
|
psets := forgepb.NewSets()
|
||||||
newpb, _, _ := psets.HttpPostVerbose(myServer(), "get")
|
newpb, _, _ := psets.HttpPostVerbose(myServer(), "get")
|
||||||
newpb.PrintTable()
|
newpb.PrintTable()
|
||||||
me.forge.Patchsets = newpb
|
me.forge.Patchsets = newpb
|
||||||
|
@ -92,38 +101,40 @@ func doPatch() error {
|
||||||
|
|
||||||
if argv.Patch.List != nil {
|
if argv.Patch.List != nil {
|
||||||
var changed bool
|
var changed bool
|
||||||
newpatches := forgepb.NewPatches()
|
newpatches := new(forgepb.Set)
|
||||||
|
newpatches.Patches = forgepb.NewPatches()
|
||||||
for pset := range me.forge.Patchsets.IterAll() {
|
for pset := range me.forge.Patchsets.IterAll() {
|
||||||
log.Info(pset.Uuid)
|
pset.PrintTable()
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
if setNewCommitHash(patch) {
|
|
||||||
changed = true
|
changed = true
|
||||||
}
|
if patch.NewHash == "" || patch.NewHash == "na" {
|
||||||
if patch.NewHash == "na" {
|
if newpatches.Patches.AppendByPatchId(patch) {
|
||||||
newpatches.Append(patch)
|
log.Info("patchId added here", patch.PatchId)
|
||||||
log.Info("apply this patch?")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
for patch := range pset.Patches.IterAll() {
|
|
||||||
if repo, ok := me.forge.IsPatchApplied(patch); ok {
|
|
||||||
log.Info("\tfound patch in repo", repo.Namespace, patch.Filename)
|
|
||||||
} else {
|
} else {
|
||||||
log.Info("\tdid not find patch", patch.CommitHash, patch.NewHash, patch.Filename)
|
log.Info("patchId already here", patch.PatchId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := setNewCommitHash(patch); err != nil {
|
||||||
|
log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info("newhash set already here", patch.PatchId, patch.NewHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
if err := me.forge.SavePatchsets(); err != nil {
|
if err := me.forge.SavePatchsets(); err != nil {
|
||||||
log.Warn("savePatchsets() failed", err)
|
log.Warn("savePatchsets() failed", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
me.forge.Patchsets.PrintTable()
|
log.Info("NEW PATCHES TABLE")
|
||||||
if newpatches.Len() != 0 {
|
newpatches.PrintTable()
|
||||||
for patch := range newpatches.IterAll() {
|
for patch := range newpatches.Patches.IterAll() {
|
||||||
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
if err := setNewCommitHash(patch); err == nil {
|
||||||
|
log.Info("newhash set already here", patch.PatchId, patch.NewHash)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
log.Infof("%s is new\n", patch.Filename)
|
||||||
repo := me.forge.FindByGoPath(patch.Namespace)
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("\tCould not find namespace:", patch.Namespace)
|
log.Info("\tCould not find namespace:", patch.Namespace)
|
||||||
|
@ -134,6 +145,17 @@ func doPatch() error {
|
||||||
log.Info("apply results:", newhash, err)
|
log.Info("apply results:", newhash, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
/*
|
||||||
|
if newpatches.Len() != 0 {
|
||||||
|
for patch := range newpatches.IterAll() {
|
||||||
|
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
|
||||||
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("\tCould not find namespace:", patch.Namespace)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
return log.Errorf("patches need to be applied")
|
return log.Errorf("patches need to be applied")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +174,7 @@ func doPatch() error {
|
||||||
}
|
}
|
||||||
newpb.PrintTable()
|
newpb.PrintTable()
|
||||||
return nil
|
return nil
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// if nothing, show patches & dirty repos
|
// if nothing, show patches & dirty repos
|
||||||
|
@ -184,7 +207,7 @@ func dumpWorkRepos() bool {
|
||||||
|
|
||||||
// returns bad if patches can not be applied
|
// returns bad if patches can not be applied
|
||||||
// logic is not great here but it was a first pass
|
// logic is not great here but it was a first pass
|
||||||
func dumpPatchset(pset *forgepb.Patchset) bool {
|
func dumpPatchset(pset *forgepb.Set) bool {
|
||||||
// don't even bother to continue if we already know it's broken
|
// don't even bother to continue if we already know it's broken
|
||||||
if pset.State == "BROKEN" {
|
if pset.State == "BROKEN" {
|
||||||
log.Printf("Patchset Name: %-24s Author: %s <%s> IS BAD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
log.Printf("Patchset Name: %-24s Author: %s <%s> IS BAD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
||||||
|
|
84
doTag.go
84
doTag.go
|
@ -7,6 +7,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/lib/fhelp"
|
"go.wit.com/lib/fhelp"
|
||||||
|
@ -23,15 +24,31 @@ func FindRepoByFullPath(wd string) *gitpb.Repo {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findCurrentPwdRepoOrDie() *gitpb.Repo {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
repo := FindRepoByFullPath(wd)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("Could not find repo:", wd)
|
||||||
|
badExit(err)
|
||||||
|
}
|
||||||
|
return repo
|
||||||
|
}
|
||||||
|
|
||||||
func doTag() error {
|
func doTag() error {
|
||||||
|
wd, _ := os.Getwd()
|
||||||
if argv.Tag.List != nil {
|
if argv.Tag.List != nil {
|
||||||
log.Info("list tags here")
|
repo := findCurrentPwdRepoOrDie()
|
||||||
|
|
||||||
|
tagTablePB := makeTagTablePB(repo, repo.Tags)
|
||||||
|
// tbox := win.Bottom.Box().SetProgName("TBOX")
|
||||||
|
// t.SetParent(tbox)
|
||||||
|
tagTablePB.MakeTable()
|
||||||
|
tagTablePB.PrintTable()
|
||||||
|
log.Info("list tags here", repo.Namespace)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Tag.Delete != "" {
|
if argv.Tag.Delete != "" {
|
||||||
wd, _ := os.Getwd()
|
|
||||||
|
|
||||||
repo := FindRepoByFullPath(wd)
|
repo := FindRepoByFullPath(wd)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("Could not find repo:", wd)
|
log.Info("Could not find repo:", wd)
|
||||||
|
@ -39,13 +56,15 @@ func doTag() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the git tag already exists somehow
|
// check if the git tag already exists somehow
|
||||||
testtag := argv.Tag.Delete
|
/*
|
||||||
if !repo.LocalTagExists(testtag) {
|
if !repo.LocalTagExists(testtag) {
|
||||||
log.Info("Tag", testtag, "does not exist")
|
log.Info("Tag", testtag, "does not exist")
|
||||||
return log.Errorf("%s TAG DOES NOT EXIST %s", repo.FullPath, testtag)
|
return log.Errorf("%s TAG DOES NOT EXIST %s", repo.FullPath, testtag)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
testtag := argv.Tag.Delete
|
||||||
if !argv.Force {
|
if !argv.Force {
|
||||||
if !fhelp.QuestionUser("delete this tag?") {
|
if !fhelp.QuestionUser(log.Sprintf("delete tag '%s'?", testtag)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,37 +76,50 @@ func doTag() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ns := "go.wit.com/apps/forge"
|
|
||||||
repo := me.forge.Repos.FindByNamespace(ns)
|
|
||||||
if repo == nil {
|
|
||||||
return log.Errorf("could not find %s", ns)
|
|
||||||
}
|
|
||||||
|
|
||||||
tagTablePB := makeTagTablePB(repo.Tags)
|
|
||||||
// tbox := win.Bottom.Box().SetProgName("TBOX")
|
|
||||||
// t.SetParent(tbox)
|
|
||||||
tagTablePB.MakeTable()
|
|
||||||
tagTablePB.PrintTable()
|
|
||||||
|
|
||||||
log.Info("do other tag stuff here")
|
log.Info("do other tag stuff here")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeTagTablePB(pb *gitpb.GitTags) *gitpb.GitTagsTable {
|
func makeTagTablePB(repo *gitpb.Repo, pb *gitpb.GitTags) *gitpb.GitTagsTable {
|
||||||
t := pb.NewTable("tagList")
|
t := pb.NewTable("tagList")
|
||||||
t.NewUuid()
|
t.NewUuid()
|
||||||
|
|
||||||
sf := t.AddStringFunc("Ref Name", func(r *gitpb.GitTag) string {
|
col := t.AddHash()
|
||||||
return r.GetRefname()
|
col.Width = 12
|
||||||
})
|
|
||||||
sf.Width = 16
|
|
||||||
|
|
||||||
colAge := t.AddTimeFunc("age", func(repo *gitpb.GitTag) time.Time {
|
col = t.AddStringFunc("bashash", func(tag *gitpb.GitTag) string {
|
||||||
|
_, base := filepath.Split(tag.Refname)
|
||||||
|
cmd, err := repo.RunStrict([]string{"git", "log", "-1", base, "--format=%H"})
|
||||||
|
if err != nil {
|
||||||
|
return "err"
|
||||||
|
}
|
||||||
|
if len(cmd.Stdout) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return cmd.Stdout[0]
|
||||||
|
})
|
||||||
|
col.Width = 12
|
||||||
|
|
||||||
|
col = t.AddTimeFunc("ctime", func(tag *gitpb.GitTag) time.Time {
|
||||||
|
// todo
|
||||||
|
return tag.Creatordate.AsTime()
|
||||||
|
})
|
||||||
|
col.Width = 4
|
||||||
|
|
||||||
|
col = t.AddTimeFunc("age", func(repo *gitpb.GitTag) time.Time {
|
||||||
// todo
|
// todo
|
||||||
return time.Now()
|
return time.Now()
|
||||||
})
|
})
|
||||||
t.AddHash()
|
col.Width = 4
|
||||||
t.AddSubject()
|
|
||||||
colAge.Width = 4
|
col = t.AddStringFunc("Ref Name", func(r *gitpb.GitTag) string {
|
||||||
|
_, ref := filepath.Split(r.GetRefname())
|
||||||
|
return ref
|
||||||
|
})
|
||||||
|
col.Width = 16
|
||||||
|
|
||||||
|
col = t.AddSubject()
|
||||||
|
col.Width = -1
|
||||||
|
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
19
doc.go
19
doc.go
|
@ -3,20 +3,14 @@ forge -- a tool to manage lots of git repos. forge includes a GUI and TUI.
|
||||||
|
|
||||||
forge only executes the 'git' command. Everything it does, you can run by hand with 'git'.
|
forge only executes the 'git' command. Everything it does, you can run by hand with 'git'.
|
||||||
|
|
||||||
forge v0.22.138-6-gaea7f16 Built on 2025.09.03_1935
|
|
||||||
Usage: forge [--debugger] [--logger] [--no-gui] [--gui GUI] [--gui-file GUI-FILE] [--gui-build] [--gui-verbose] [--gui-check-plugin GUI-CHECK-PLUGIN] [--connect CONNECT] [--all] [--build BUILD] [--install INSTALL] [--forge-rebuild] [--force] [--verbose] [--bash] [--auto-complete AUTO-COMPLETE] <command> [<args>]
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
--debugger open the debugger window
|
--debugger open the debugger window
|
||||||
--logger open the log.* control window
|
--logger open the log.* control window
|
||||||
--no-gui ignore all these gui problems
|
--gui GUI select the plugin (andlabs,gocui,etc)
|
||||||
--gui GUI Use this gui toolkit [andlabs,gocui,nocui,stdin]
|
|
||||||
--gui-file GUI-FILE Use a specific plugin.so file
|
|
||||||
--gui-build attempt to build the GUI plugins
|
|
||||||
--gui-verbose enable all logging
|
--gui-verbose enable all logging
|
||||||
--gui-check-plugin GUI-CHECK-PLUGIN
|
--bash generate bash completion
|
||||||
hack to verify GO plugins load
|
--bash generate bash completion
|
||||||
--connect CONNECT forge url
|
--connect CONNECT forge url
|
||||||
--all git commit --all
|
--all git commit --all
|
||||||
--build BUILD build a repo
|
--build BUILD build a repo
|
||||||
|
@ -24,25 +18,24 @@ Options:
|
||||||
--forge-rebuild download and rebuild forge
|
--forge-rebuild download and rebuild forge
|
||||||
--force try to strong arm things
|
--force try to strong arm things
|
||||||
--verbose show more output
|
--verbose show more output
|
||||||
--bash generate bash completion
|
|
||||||
--auto-complete AUTO-COMPLETE
|
|
||||||
todo: move this to go-arg
|
|
||||||
--help, -h display this help and exit
|
--help, -h display this help and exit
|
||||||
--version display version and exit
|
--version display version and exit
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
|
||||||
|
help New to forge? This is for you.'
|
||||||
checkout switch branches using 'git checkout'
|
checkout switch branches using 'git checkout'
|
||||||
clean start over at the beginning
|
clean start over at the beginning
|
||||||
commit 'git commit' but errors out if on wrong branch
|
commit 'git commit' but errors out if on wrong branch
|
||||||
config show your .config/forge/ settings
|
config show your .config/forge/ settings
|
||||||
debug debug forge
|
|
||||||
dirty show dirty git repos
|
dirty show dirty git repos
|
||||||
fetch run 'git fetch master'
|
fetch run 'git fetch master'
|
||||||
|
gui open the gui
|
||||||
list print a table of the current repos
|
list print a table of the current repos
|
||||||
merge merge branches
|
merge merge branches
|
||||||
normal set every repo to the default state for software development
|
normal set every repo to the default state for software development
|
||||||
patch make patchsets
|
patch make patchsets
|
||||||
pull run 'git pull'
|
pull run 'git pull'
|
||||||
|
tag manage git tags
|
||||||
*/
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
2
exit.go
2
exit.go
|
@ -28,6 +28,6 @@ func badExit(err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func badRepoExit(repo *gitpb.Repo, err error) {
|
func badRepoExit(repo *gitpb.Repo, err error) {
|
||||||
log.Printf("forge failed on %s with %v\n", repo.GetNamespace(), err)
|
log.Printf("%s FAILED: %v\n", repo.GetNamespace(), err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,33 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func makeReposTablePB(pb *gitpb.Repos) *gitpb.ReposTable {
|
||||||
|
t := pb.NewTable("quickListRepos")
|
||||||
|
t.NewUuid()
|
||||||
|
|
||||||
|
sf := t.AddStringFunc("Namespace", func(r *gitpb.Repo) string {
|
||||||
|
return r.GetNamespace()
|
||||||
|
})
|
||||||
|
sf.Width = 16
|
||||||
|
|
||||||
|
userVer := t.AddStringFunc("user", func(repo *gitpb.Repo) string {
|
||||||
|
ver := repo.GetUserVersion()
|
||||||
|
return ver
|
||||||
|
})
|
||||||
|
userVer.Width = 4
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
type stdPatchsetTableWin struct {
|
type stdPatchsetTableWin struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
win *gadgets.GenericWindow // the machines gui window
|
win *gadgets.GenericWindow // the machines gui window
|
||||||
box *gui.Node // the machines gui parent box widget
|
box *gui.Node // the machines gui parent box widget
|
||||||
TB *forgepb.PatchsetsTable // the gui table buffer
|
TB *forgepb.SetsTable // the gui table buffer
|
||||||
update bool // if the window should be updated
|
update bool // if the window should be updated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +54,7 @@ func (w *stdPatchsetTableWin) Toggle() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
etimef := func(e *forgepb.Patchset) string {
|
etimef := func(e *forgepb.Set) string {
|
||||||
etime := e.Etime.AsTime()
|
etime := e.Etime.AsTime()
|
||||||
s := etime.Format("2006/01/02 15:04")
|
s := etime.Format("2006/01/02 15:04")
|
||||||
if strings.HasPrefix(s, "1970/") {
|
if strings.HasPrefix(s, "1970/") {
|
||||||
|
@ -49,14 +67,14 @@ func (w *stdPatchsetTableWin) Toggle() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ctimef := func(p *forgepb.Patchset) string {
|
ctimef := func(p *forgepb.Set) string {
|
||||||
ctime := p.Ctime.AsTime()
|
ctime := p.Ctime.AsTime()
|
||||||
return ctime.Format("2006/01/02 15:04")
|
return ctime.Format("2006/01/02 15:04")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func setPatchsetState(p *forgepb.Patchset) {
|
func setPatchsetState(p *forgepb.Set) {
|
||||||
var bad bool
|
var bad bool
|
||||||
var good bool
|
var good bool
|
||||||
var done bool = true
|
var done bool = true
|
||||||
|
@ -155,53 +173,33 @@ func findCommitBySubject(subject string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if PB changed
|
// returns true if PB changed
|
||||||
func setNewCommitHash(patch *forgepb.Patch) bool {
|
func setNewCommitHash(patch *forgepb.Patch) error {
|
||||||
// parts := strings.Fields(patch.Comment)
|
|
||||||
|
|
||||||
repo := me.forge.FindByGoPath(patch.Namespace)
|
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
log.Info("could not find repo", patch.Namespace)
|
return log.Errorf("could not find repo %s", patch.Namespace)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
|
||||||
if patch.NewHash == "" {
|
|
||||||
log.Info("init() new patch to 'na' ", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
|
||||||
patch.NewHash = "na"
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
os.Chdir(repo.GetFullPath())
|
os.Chdir(repo.GetFullPath())
|
||||||
newhash, err := findCommitBySubject(comment)
|
newhash, err := findCommitBySubject(comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("patch: not found hash:", patch.CommitHash, patch.Namespace, comment, newhash, err)
|
return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
if patch.NewHash == newhash {
|
|
||||||
// patch was already set
|
patchId, err := repo.FindPatchId(newhash)
|
||||||
return false
|
if err != nil {
|
||||||
}
|
return err
|
||||||
if patch.NewHash != "na" {
|
|
||||||
log.Infof("patch: hash MISMATCH %s old=%s new=%s name=%s\n", patch.Namespace, patch.NewHash, newhash, comment)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch.PatchId = patchId
|
||||||
patch.NewHash = newhash
|
patch.NewHash = newhash
|
||||||
|
|
||||||
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
|
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
|
||||||
return true
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
|
||||||
func setNewCommitHashLoop(p *forgepb.Patchset) bool {
|
|
||||||
var done bool = true
|
|
||||||
for patch := range p.Patches.IterAll() {
|
|
||||||
setNewCommitHashLoop(patch)
|
|
||||||
}
|
|
||||||
|
|
||||||
return done
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
|
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
|
||||||
|
@ -215,7 +213,7 @@ func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
|
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bo
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "" {
|
||||||
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -283,7 +281,7 @@ func findExpired() *forgepb.Patches {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "" {
|
||||||
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
|
||||||
found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
found.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
||||||
continue
|
continue
|
||||||
|
|
48
main.go
48
main.go
|
@ -7,13 +7,9 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/lib/gui/prep"
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"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"
|
||||||
|
@ -43,24 +39,17 @@ func getVersion(repo *gitpb.Repo, name string) string {
|
||||||
return strings.TrimSpace(output)
|
return strings.TrimSpace(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadCheck(repo *gitpb.Repo) error {
|
|
||||||
if err := repo.ReloadCheck(); err != nil {
|
|
||||||
log.Info("changed:", repo.FullPath)
|
|
||||||
configSave = true
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(mainType)
|
me = new(mainType)
|
||||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
|
||||||
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
||||||
me.pp = arg.MustParse(&argv)
|
me.auto = prep.Bash3(&argv) // this line should be: prep.Bash(&argv)
|
||||||
|
|
||||||
me.forge = forgepb.Init()
|
// me.auto = prep.Bash3(argv.DoAutoComplete, &argv) // this line should be: prep.Bash(&argv)
|
||||||
// me.forge.RillRepos(reloadCheck)
|
// arg.MustParse(&argv) // these three lines are becoming terrible syntax
|
||||||
me.forge.ScanGoSrc()
|
// me.auto = prep.MustParse(&argv) // try to make this work?
|
||||||
|
|
||||||
|
me.forge = forgepb.Init() // init forge.pb
|
||||||
|
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
|
||||||
|
|
||||||
// initialize patches
|
// initialize patches
|
||||||
doPatchInit()
|
doPatchInit()
|
||||||
|
@ -82,7 +71,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Checkout != nil {
|
if argv.Checkout != nil {
|
||||||
setForgeMode(forgepb.ForgeMode_MASTER)
|
|
||||||
if err := doCheckout(); err != nil {
|
if err := doCheckout(); err != nil {
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
|
@ -142,7 +130,7 @@ func main() {
|
||||||
log.Info("you were aleady not in the normal state")
|
log.Info("you were aleady not in the normal state")
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
setForgeMode(forgepb.ForgeMode_MASTER)
|
setForgeMode(forgepb.ForgeMode_DEVEL)
|
||||||
log.Info("normal mode off")
|
log.Info("normal mode off")
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
@ -167,30 +155,12 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Merge != nil {
|
if argv.Merge != nil {
|
||||||
if argv.Merge.Devel != nil {
|
if err := doMerge(); err != nil {
|
||||||
start := time.Now()
|
|
||||||
repos, err := doMergeDevel()
|
|
||||||
dur := time.Since(start)
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
badExit(err)
|
||||||
}
|
}
|
||||||
log.Printf("Merged %d devel branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
|
||||||
okExit("")
|
okExit("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Merge.Master != nil {
|
|
||||||
start := time.Now()
|
|
||||||
repos, err := doMergeMaster()
|
|
||||||
dur := time.Since(start)
|
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
log.Printf("Merged %d master branches in %s\n", repos.Len(), shell.FormatDuration(dur))
|
|
||||||
okExit("")
|
|
||||||
}
|
|
||||||
badExit(fmt.Errorf("You must choose which branch to merge to (devel or master)"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if argv.Pull != nil {
|
if argv.Pull != nil {
|
||||||
doPull()
|
doPull()
|
||||||
okExit("")
|
okExit("")
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/lib/gui/prep"
|
||||||
|
@ -28,7 +27,8 @@ func myServer() string {
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type mainType struct {
|
type mainType struct {
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
// pp *arg.Parser // for parsing the command line args. Yay to alexflint!
|
||||||
|
auto *prep.Auto // more experiments for bash handling
|
||||||
forge *forgepb.Forge // for holding the forge protobuf files
|
forge *forgepb.Forge // for holding the forge protobuf files
|
||||||
myGui *prep.GuiPrep // for initializing the GUI toolkits
|
myGui *prep.GuiPrep // for initializing the GUI toolkits
|
||||||
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
||||||
|
|
|
@ -117,11 +117,8 @@ func applyPatchLabel(p *forgepb.Patch) string {
|
||||||
// log.Info("Could not figure out repo path", rn)
|
// log.Info("Could not figure out repo path", rn)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if p.NewHash == "na" {
|
|
||||||
return "git am"
|
|
||||||
}
|
|
||||||
if p.NewHash == "" {
|
if p.NewHash == "" {
|
||||||
return "new"
|
return "git am"
|
||||||
}
|
}
|
||||||
return "done"
|
return "done"
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ type repoPatchWindow struct {
|
||||||
grid *gui.Node // the list of available patches
|
grid *gui.Node // the list of available patches
|
||||||
// summary *patchSummary // summary of current patches
|
// summary *patchSummary // summary of current patches
|
||||||
setgrid *gui.Node // the list of each patchset
|
setgrid *gui.Node // the list of each patchset
|
||||||
pset *forgepb.Patchset // the patchset in question
|
pset *forgepb.Set // the patchset in question
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: autogenerate these or make them standared 'gui' package functions
|
// todo: autogenerate these or make them standared 'gui' package functions
|
||||||
|
@ -109,7 +109,7 @@ func makeRepoPatchWindow(repo *gitpb.Repo, fset []*forgepb.Patch) *repoPatchWind
|
||||||
return pw
|
return pw
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *repoPatchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
|
func (r *repoPatchWindow) addPatchset(grid *gui.Node, pset *forgepb.Set) {
|
||||||
repomap := make(map[*gitpb.Repo][]*forgepb.Patch)
|
repomap := make(map[*gitpb.Repo][]*forgepb.Patch)
|
||||||
repohash := make(map[*gitpb.Repo]string)
|
repohash := make(map[*gitpb.Repo]string)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue