dump patchsets to the console
This commit is contained in:
parent
f26e5e9980
commit
4d4aad27e4
3
Makefile
3
Makefile
|
@ -7,7 +7,8 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
||||||
# make andlabs # try the andlabs gui plugin (uses GTK)
|
# make andlabs # try the andlabs gui plugin (uses GTK)
|
||||||
|
|
||||||
default: install
|
default: install
|
||||||
forge dirty --verbose
|
# forge dirty --verbose
|
||||||
|
forge patch list
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@GO111MODULE=off go vet
|
@GO111MODULE=off go vet
|
||||||
|
|
|
@ -42,52 +42,6 @@ func savePatchset(pset *forgepb.Patchset) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns bad if patches can not be applied
|
|
||||||
func dumpPatchset(pset *forgepb.Patchset) bool {
|
|
||||||
log.Info("applyPatches() NAME", pset.Name)
|
|
||||||
log.Info("applyPatches() COMMENT", pset.Comment)
|
|
||||||
log.Info("applyPatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName())
|
|
||||||
log.Info("applyPatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
|
|
||||||
log.Info("applyPatches() Branch Name", pset.GetStartBranchName())
|
|
||||||
log.Info("applyPatches() Start Hash", pset.GetStartBranchHash())
|
|
||||||
|
|
||||||
var count int
|
|
||||||
var bad int
|
|
||||||
all := pset.Patches.SortByFilename()
|
|
||||||
for all.Scan() {
|
|
||||||
p := all.Next()
|
|
||||||
if IsValidPatch(p) {
|
|
||||||
// ok
|
|
||||||
} else {
|
|
||||||
bad += 1
|
|
||||||
}
|
|
||||||
count += 1
|
|
||||||
}
|
|
||||||
log.Info("pset has", count, "total patches, ", bad, "bad patches")
|
|
||||||
if bad == 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsValidPatch(p *forgepb.Patch) bool {
|
|
||||||
basepath, filename := filepath.Split(p.Filename)
|
|
||||||
repo := me.forge.FindByGoPath(basepath)
|
|
||||||
if repo == nil {
|
|
||||||
log.Info("can not apply patch! repo not found", basepath, filename)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if repo.DevelHash() != p.StartHash {
|
|
||||||
log.Info("can not apply patch! devel hash mismatch", basepath, filename)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
log.Info("start:", p.StartHash, "end:", p.CommitHash, "file:", basepath, filename, "devel version", repo.GetDevelVersion())
|
|
||||||
for _, line := range p.Files {
|
|
||||||
log.Info("\t", line)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// re-run git CheckDirty() on everything
|
// re-run git CheckDirty() on everything
|
||||||
func IsAnythingDirty() bool {
|
func IsAnythingDirty() bool {
|
||||||
me.found = new(gitpb.Repos)
|
me.found = new(gitpb.Repos)
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func doPatch() error {
|
||||||
|
if argv.Patch.Submit != "" {
|
||||||
|
_, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if argv.Patch.List != nil {
|
||||||
|
return doPatchList()
|
||||||
|
}
|
||||||
|
findReposWithPatches()
|
||||||
|
if me.found.Len() == 0 {
|
||||||
|
log.Info("you have no patches in your user branches")
|
||||||
|
okExit("patch list empty")
|
||||||
|
}
|
||||||
|
me.forge.PrintHumanTable(me.found)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func doPatchList() error {
|
||||||
|
psets, err := me.forge.GetPatchesets()
|
||||||
|
if err != nil {
|
||||||
|
log.Info("Get Patchsets failed", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info("got psets len", len(psets.Patchsets))
|
||||||
|
all := psets.SortByName()
|
||||||
|
for all.Scan() {
|
||||||
|
pset := all.Next()
|
||||||
|
log.Info("pset name =", pset.Name)
|
||||||
|
dumpPatchset(pset)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns bad if patches can not be applied
|
||||||
|
func dumpPatchset(pset *forgepb.Patchset) bool {
|
||||||
|
log.Info("applyPatches() NAME", pset.Name)
|
||||||
|
log.Info("applyPatches() COMMENT", pset.Comment)
|
||||||
|
log.Info("applyPatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName())
|
||||||
|
log.Info("applyPatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
|
||||||
|
log.Info("applyPatches() Branch Name", pset.GetStartBranchName())
|
||||||
|
log.Info("applyPatches() Start Hash", pset.GetStartBranchHash())
|
||||||
|
|
||||||
|
var count int
|
||||||
|
var bad int
|
||||||
|
all := pset.Patches.SortByFilename()
|
||||||
|
for all.Scan() {
|
||||||
|
p := all.Next()
|
||||||
|
if IsValidPatch(p) {
|
||||||
|
// ok
|
||||||
|
} else {
|
||||||
|
bad += 1
|
||||||
|
}
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
log.Info("pset has", count, "total patches, ", bad, "bad patches")
|
||||||
|
if bad == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsValidPatch(p *forgepb.Patch) bool {
|
||||||
|
basepath, filename := filepath.Split(p.Filename)
|
||||||
|
repo := me.forge.FindByGoPath(basepath)
|
||||||
|
if repo == nil {
|
||||||
|
log.Info("can not apply patch! repo not found", basepath, filename)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if repo.DevelHash() != p.StartHash {
|
||||||
|
log.Info("can not apply patch! devel hash mismatch", basepath, filename)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
log.Info("start:", p.StartHash, "end:", p.CommitHash, "file:", basepath, filename, "devel version", repo.GetDevelVersion())
|
||||||
|
for _, line := range p.Files {
|
||||||
|
log.Info("\t", line)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
29
main.go
29
main.go
|
@ -155,34 +155,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Patch != nil {
|
if argv.Patch != nil {
|
||||||
if argv.Patch.Submit != "" {
|
if err := doPatch(); err != nil {
|
||||||
_, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit)
|
badExit(err)
|
||||||
if err != nil {
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
okExit("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Patch.List != nil {
|
|
||||||
if psets, err := me.forge.GetPatchesets(); err != nil {
|
|
||||||
log.Info("Get Patchsets failed", err)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
log.Info("got psets len", len(psets.Patchsets))
|
|
||||||
all := psets.SortByName()
|
|
||||||
for all.Scan() {
|
|
||||||
pset := all.Next()
|
|
||||||
log.Info("pset name =", pset.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
findReposWithPatches()
|
|
||||||
if me.found.Len() == 0 {
|
|
||||||
log.Info("you have no patches in your user branches")
|
|
||||||
okExit("patch list empty")
|
|
||||||
}
|
|
||||||
me.forge.PrintHumanTable(me.found)
|
|
||||||
|
|
||||||
okExit("patch list")
|
okExit("patch list")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,8 +101,8 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
grid.NewButton("Apply with git am", func() {
|
grid.NewButton("Apply with git am", func() {
|
||||||
if _, _, _, err := IsEverythingOnDevel(); err != nil {
|
if _, _, _, err := IsEverythingOnUser(); err != nil {
|
||||||
log.Info("You can only apply patches to the devel branch")
|
log.Info("You can only apply patches to the user branch")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if IsAnythingDirty() {
|
if IsAnythingDirty() {
|
||||||
|
|
Loading…
Reference in New Issue