set patch NewHash
This commit is contained in:
parent
790c48e0d0
commit
e639f7d7b7
12
Makefile
12
Makefile
|
@ -6,17 +6,13 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
|
|||
# make gocui # try the ncurses gui plugin
|
||||
# make andlabs # try the andlabs gui plugin (uses GTK)
|
||||
|
||||
default: verbose install
|
||||
forge patch
|
||||
default: install-verbose
|
||||
forge patch list
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
@echo this go binary package builds okay
|
||||
|
||||
verbose: goimports vet plugin
|
||||
GO111MODULE=off go install -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
build: goimports vet plugin
|
||||
GO111MODULE=off go build \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
@ -26,6 +22,10 @@ install: goimports plugin
|
|||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
cp -f ~/go/bin/forge ~/go/bin/last.forge # this is a hack so that go-deb can build a .deb file for forge # TODO: remove this
|
||||
|
||||
install-verbose: goimports vet plugin
|
||||
GO111MODULE=off go install -v -x \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
||||
install-raw: goimports vet plugin
|
||||
go install \
|
||||
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
|
||||
|
|
12
doGui.go
12
doGui.go
|
@ -179,20 +179,9 @@ func drawWindow(win *gadgets.GenericWindow) {
|
|||
patchesWin.Toggle()
|
||||
return
|
||||
}
|
||||
// load the current patches protobuf file
|
||||
if err := me.forge.LoadPatchsets(); err != nil {
|
||||
log.Info("patches failed to open", err)
|
||||
if err := me.forge.SavePatchsets(); err != nil {
|
||||
log.Warn("savePatchsets() failed", err)
|
||||
}
|
||||
}
|
||||
// patchesWin = makePatchesWin(me.forge.Patchsets)
|
||||
notdone := new(forgepb.Patches)
|
||||
|
||||
if me.forge.Patchsets == nil {
|
||||
log.Info("patchsets == nil")
|
||||
return
|
||||
}
|
||||
all := me.forge.Patchsets.All()
|
||||
for all.Scan() {
|
||||
pset := all.Next()
|
||||
|
@ -203,6 +192,7 @@ func drawWindow(win *gadgets.GenericWindow) {
|
|||
AddAllPatches(notdone, pset, false)
|
||||
// AddNotDonePatches(notdone, pset, false)
|
||||
}
|
||||
notdone.PrintTable()
|
||||
|
||||
patchesWin = makePatchesWin(notdone)
|
||||
})
|
||||
|
|
43
doPatch.go
43
doPatch.go
|
@ -10,14 +10,19 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func doPatch() error {
|
||||
func doPatchInit() {
|
||||
if me.forge.Patchsets != nil {
|
||||
log.Info("IGNORE: patches already initalized")
|
||||
}
|
||||
if err := me.forge.LoadPatchsets(); err != nil {
|
||||
log.Info("patches failed to open", err)
|
||||
if err := me.forge.SavePatchsets(); err != nil {
|
||||
log.Warn("savePatchsets() failed", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func doPatch() error {
|
||||
if argv.Patch.Submit != nil {
|
||||
_, err := me.forge.SubmitDevelPatchSet(argv.Patch.Submit.Match)
|
||||
if err != nil {
|
||||
|
@ -43,21 +48,35 @@ func doPatch() error {
|
|||
}
|
||||
|
||||
if argv.Patch.Check != nil {
|
||||
for pset := range me.forge.Patchsets.IterAll() {
|
||||
log.Info(pset.Uuid)
|
||||
for patch := range pset.Patches.IterAll() {
|
||||
if repo, ok := me.forge.IsPatchApplied(patch); ok {
|
||||
log.Info("found patch in repo", repo.Namespace, patch.Filename)
|
||||
} else {
|
||||
// log.Info("did not find patch", patch.CommitHash, patch.NewHash, patch.Filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
// me.forge.Patchsets.PrintTable()
|
||||
log.Info("remove this option")
|
||||
return nil
|
||||
}
|
||||
|
||||
if argv.Patch.List != nil {
|
||||
var changed bool
|
||||
for pset := range me.forge.Patchsets.IterAll() {
|
||||
log.Info(pset.Uuid)
|
||||
for patch := range pset.Patches.IterAll() {
|
||||
if setNewCommitHash(patch) {
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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 err := me.forge.SavePatchsets(); err != nil {
|
||||
log.Warn("savePatchsets() failed", err)
|
||||
}
|
||||
}
|
||||
me.forge.Patchsets.PrintTable()
|
||||
// return doPatchList()
|
||||
return nil
|
||||
|
|
|
@ -154,36 +154,52 @@ func findCommitBySubject(subject string) (string, error) {
|
|||
return "", fmt.Errorf("no commit found for subject: %s", subject)
|
||||
}
|
||||
|
||||
func setNewCommitHash(p *forgepb.Patchset) bool {
|
||||
var done bool = true
|
||||
for patch := range p.Patches.IterAll() {
|
||||
// returns true if PB changed
|
||||
func setNewCommitHash(patch *forgepb.Patch) bool {
|
||||
// parts := strings.Fields(patch.Comment)
|
||||
|
||||
repo := me.forge.FindByGoPath(patch.Namespace)
|
||||
if repo == nil {
|
||||
log.Info("could not find repo", patch.Namespace)
|
||||
continue
|
||||
return false
|
||||
}
|
||||
|
||||
comment := cleanSubject(patch.Comment)
|
||||
|
||||
if patch.NewHash != "na" {
|
||||
log.Info("patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
||||
continue
|
||||
if patch.NewHash == "" {
|
||||
log.Info("init() new patch to 'na' ", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
||||
patch.NewHash = "na"
|
||||
return true
|
||||
}
|
||||
done = false
|
||||
os.Chdir(repo.GetFullPath())
|
||||
newhash, err := findCommitBySubject(comment)
|
||||
if err != nil {
|
||||
log.Info("patch: not found hash:", patch.CommitHash, patch.Namespace, comment, newhash, err)
|
||||
continue
|
||||
return false
|
||||
}
|
||||
if patch.NewHash == newhash {
|
||||
// patch was already set
|
||||
return false
|
||||
}
|
||||
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.NewHash = newhash
|
||||
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
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() {
|
||||
|
|
3
main.go
3
main.go
|
@ -79,6 +79,9 @@ func main() {
|
|||
// load the ~/.config/forge/ config
|
||||
me.forge = forgepb.Init()
|
||||
|
||||
// initialize patches
|
||||
doPatchInit()
|
||||
|
||||
// first find the repos or gopaths to operate on
|
||||
if argv.Config != nil {
|
||||
doConfig()
|
||||
|
|
|
@ -133,13 +133,27 @@ func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
|
|||
}
|
||||
|
||||
// used by the PB table
|
||||
func funcApplyPatch(p *forgepb.Patch) string {
|
||||
func applyPatchLabel(p *forgepb.Patch) string {
|
||||
rn := p.Namespace
|
||||
if repo := me.forge.FindByGoPath(rn); repo == nil {
|
||||
// log.Info("Could not figure out repo path", rn)
|
||||
return ""
|
||||
}
|
||||
if p.NewHash == "na" {
|
||||
return "git am"
|
||||
}
|
||||
if p.NewHash == "" {
|
||||
return "new"
|
||||
}
|
||||
return "done"
|
||||
}
|
||||
|
||||
func applyPatchClick(p *forgepb.Patch) {
|
||||
if err := applyPatchNew(p); err != nil {
|
||||
log.Info("git am failed on file", p.Filename, "with error", err)
|
||||
return
|
||||
}
|
||||
log.Info("ran: git am", p.Filename, "ok")
|
||||
}
|
||||
|
||||
// define what rows to have in the protobuf table
|
||||
|
@ -148,21 +162,8 @@ func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
|
|||
t.NewUuid()
|
||||
t.SetParent(tbox)
|
||||
|
||||
gitam := t.AddButtonFunc("apply", func(p *forgepb.Patch) string {
|
||||
rn := p.Namespace
|
||||
if repo := me.forge.FindByGoPath(rn); repo == nil {
|
||||
// log.Info("Could not figure out repo path", rn)
|
||||
return ""
|
||||
}
|
||||
return "git am"
|
||||
})
|
||||
gitam.Custom = func(p *forgepb.Patch) {
|
||||
if err := applyPatchNew(p); err != nil {
|
||||
log.Info("git am failed on file", p.Filename, "with error", err)
|
||||
return
|
||||
}
|
||||
log.Info("ran: git am", p.Filename, "ok")
|
||||
}
|
||||
gitam := t.AddButtonFunc("apply", applyPatchLabel)
|
||||
gitam.Custom = applyPatchClick
|
||||
|
||||
t.AddCommitHash()
|
||||
t.AddNamespace()
|
||||
|
|
Loading…
Reference in New Issue