Compare commits

...

6 Commits

Author SHA1 Message Date
Jeff Carr e0520ca96d apply patches 2025-09-23 14:50:59 -05:00
Jeff Carr 6d7d74feb4 fixing against new .proto files 2025-09-23 14:21:58 -05:00
Jeff Carr 9c87e1a040 print the table of the patches 2025-09-23 09:36:05 -05:00
Jeff Carr bda5fb4fbe set PB tables are working 2025-09-23 09:02:00 -05:00
Jeff Carr 1e3f4a3b9f new .proto files 2025-09-23 07:43:30 -05:00
Jeff Carr e300719241 cleanup tag list 2025-09-22 23:02:59 -05:00
7 changed files with 153 additions and 154 deletions

14
argv.go
View File

@ -155,7 +155,7 @@ func DoAutoComplete(pb *prep.Auto) {
case "checkout": case "checkout":
pb.Autocomplete2("devel master user") pb.Autocomplete2("devel master user")
case "clean": case "clean":
fmt.Println("--force verify --repo") pb.Autocomplete2("")
case "commit": case "commit":
pb.Autocomplete2("--all") pb.Autocomplete2("--all")
case "config": case "config":
@ -171,19 +171,11 @@ func DoAutoComplete(pb *prep.Auto) {
case "merge": case "merge":
pb.Autocomplete2("devel master --all") 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:

View File

@ -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,66 +101,80 @@ 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 newpatches.Patches.AppendByPatchId(patch) {
if patch.NewHash == "na" { log.Info("patchId added here", patch.PatchId)
newpatches.Append(patch) } else {
log.Info("apply this patch?") 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)
} }
} }
/*
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 {
log.Info("\tdid not find patch", patch.CommitHash, patch.NewHash, patch.Filename)
}
}
*/
} }
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 {
repo := me.forge.FindByGoPath(patch.Namespace) log.Info("newhash set already here", patch.PatchId, patch.NewHash)
if repo == nil { continue
log.Info("\tCould not find namespace:", patch.Namespace) }
continue log.Infof("%s is new\n", patch.Filename)
} repo := me.forge.FindByGoPath(patch.Namespace)
if fhelp.QuestionUser("apply this patch?") { if repo == nil {
newhash, err := applyAndTrackPatch(repo, patch) log.Info("\tCould not find namespace:", patch.Namespace)
log.Info("apply results:", newhash, err) continue
} }
if fhelp.QuestionUser("apply this patch?") {
newhash, err := applyAndTrackPatch(repo, patch)
log.Info("apply results:", newhash, err)
} }
return log.Errorf("patches need to be applied")
} }
// return doPatchList()
applied := findApplied()
if applied == nil || applied.Len() == 0 {
log.Info("no patches have been appled to the devel branch yet")
return nil
}
// for patch := range applied.IterAll() {
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
// }
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
if err != nil {
return err
}
newpb.PrintTable()
return nil 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 doPatchList()
applied := findApplied()
if applied == nil || applied.Len() == 0 {
log.Info("no patches have been appled to the devel branch yet")
return nil
}
// for patch := range applied.IterAll() {
// log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
// }
newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
if err != nil {
return err
}
newpb.PrintTable()
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())

View File

@ -39,7 +39,7 @@ func doTag() error {
if argv.Tag.List != nil { if argv.Tag.List != nil {
repo := findCurrentPwdRepoOrDie() repo := findCurrentPwdRepoOrDie()
tagTablePB := makeTagTablePB(repo.Tags) tagTablePB := makeTagTablePB(repo, repo.Tags)
// tbox := win.Bottom.Box().SetProgName("TBOX") // tbox := win.Bottom.Box().SetProgName("TBOX")
// t.SetParent(tbox) // t.SetParent(tbox)
tagTablePB.MakeTable() tagTablePB.MakeTable()
@ -80,40 +80,46 @@ func doTag() error {
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()
col := t.AddHash() col := t.AddHash()
col.Width = 12 col.Width = 12
col = t.AddStringFunc("Ref Name", func(r *gitpb.GitTag) string { col = t.AddStringFunc("bashash", func(tag *gitpb.GitTag) string {
_, ref := filepath.Split(r.GetRefname()) _, base := filepath.Split(tag.Refname)
return ref 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 = 16 col.Width = 12
// col.Width = -1
col = t.AddTimeFunc("age", func(repo *gitpb.GitTag) time.Time {
// todo
return time.Now()
})
col.Width = 6
col = t.AddTimeFunc("ctime", func(tag *gitpb.GitTag) time.Time { col = t.AddTimeFunc("ctime", func(tag *gitpb.GitTag) time.Time {
// todo // todo
return tag.Creatordate.AsTime() return tag.Creatordate.AsTime()
}) })
col.Width = 16 col.Width = 4
col = t.AddIntFunc("int", func(tag *gitpb.GitTag) int { col = t.AddTimeFunc("age", func(repo *gitpb.GitTag) time.Time {
// todo // todo
return 3 return time.Now()
}) })
col.Width = 4 col.Width = 4
col = t.AddSubject() col = t.AddStringFunc("Ref Name", func(r *gitpb.GitTag) string {
_, ref := filepath.Split(r.GetRefname())
return ref
})
col.Width = 16 col.Width = 16
col = t.AddSubject()
col.Width = -1
return t return t
} }

61
doc.go
View File

@ -1,40 +1,41 @@
/* /*
forge -- a tool to manage lots of git repos. forge includes a GUI and TUI. 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'.
Options: Options:
--debugger open the debugger window
--logger open the log.* control window --debugger open the debugger window
--gui GUI select the plugin (andlabs,gocui,etc) --logger open the log.* control window
--gui-verbose enable all logging --gui GUI select the plugin (andlabs,gocui,etc)
--bash generate bash completion --gui-verbose enable all logging
--bash generate bash completion --bash generate bash completion
--connect CONNECT forge url --bash generate bash completion
--all git commit --all --connect CONNECT forge url
--build BUILD build a repo --all git commit --all
--install INSTALL install a repo --build BUILD build a repo
--forge-rebuild download and rebuild forge --install INSTALL install a repo
--force try to strong arm things --forge-rebuild download and rebuild forge
--verbose show more output --force try to strong arm things
--help, -h display this help and exit --verbose show more output
--version display version and exit --help, -h display this help and exit
--version display version and exit
Commands: Commands:
help New to forge? This is for you.'
checkout switch branches using 'git checkout' help New to forge? This is for you.'
clean start over at the beginning checkout switch branches using 'git checkout'
commit 'git commit' but errors out if on wrong branch clean start over at the beginning
config show your .config/forge/ settings commit 'git commit' but errors out if on wrong branch
dirty show dirty git repos config show your .config/forge/ settings
fetch run 'git fetch master' dirty show dirty git repos
gui open the gui fetch run 'git fetch master'
list print a table of the current repos gui open the gui
merge merge branches list print a table of the current repos
normal set every repo to the default state for software development merge merge branches
patch make patchsets normal set every repo to the default state for software development
pull run 'git pull' patch make patchsets
tag manage git tags pull run 'git pull'
tag manage git tags
*/ */
package main package main

View File

@ -38,7 +38,7 @@ 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
} }
@ -54,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/") {
@ -67,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
@ -173,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)
@ -233,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)
@ -251,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
} }
@ -301,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

View File

@ -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"
} }

View File

@ -21,8 +21,8 @@ type repoPatchWindow struct {
shelf *gui.Node // the first box in the stack, set as horizontal shelf *gui.Node // the first box in the stack, set as horizontal
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)