Compare commits

...

2 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
3 changed files with 75 additions and 84 deletions

View File

@ -101,38 +101,40 @@ func doPatch() error {
if argv.Patch.List != nil {
var changed bool
newpatches := forgepb.NewPatches()
newpatches := new(forgepb.Set)
newpatches.Patches = forgepb.NewPatches()
for pset := range me.forge.Patchsets.IterAll() {
log.Info(pset.Uuid)
pset.PrintTable()
for patch := range pset.Patches.IterAll() {
if setNewCommitHash(patch) {
changed = true
}
if patch.NewHash == "na" {
newpatches.Append(patch)
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)
if patch.NewHash == "" || patch.NewHash == "na" {
if newpatches.Patches.AppendByPatchId(patch) {
log.Info("patchId added here", patch.PatchId)
} 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 err := me.forge.SavePatchsets(); err != nil {
log.Warn("savePatchsets() failed", err)
}
}
me.forge.Patchsets.PrintTable()
if newpatches.Len() != 0 {
for patch := range newpatches.IterAll() {
log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
log.Info("NEW PATCHES TABLE")
newpatches.PrintTable()
for patch := range newpatches.Patches.IterAll() {
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)
if repo == nil {
log.Info("\tCould not find namespace:", patch.Namespace)
@ -143,6 +145,17 @@ func doPatch() error {
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")
}
@ -161,6 +174,7 @@ func doPatch() error {
}
newpb.PrintTable()
return nil
*/
}
// if nothing, show patches & dirty repos

View File

@ -173,52 +173,32 @@ func findCommitBySubject(subject string) (string, error) {
}
// returns true if PB changed
func setNewCommitHash(patch *forgepb.Patch) bool {
// parts := strings.Fields(patch.Comment)
func setNewCommitHash(patch *forgepb.Patch) error {
repo := me.forge.FindByGoPath(patch.Namespace)
if repo == nil {
log.Info("could not find repo", patch.Namespace)
return false
return log.Errorf("could not find repo %s", patch.Namespace)
}
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())
newhash, err := findCommitBySubject(comment)
if err != nil {
log.Info("patch: not found hash:", patch.CommitHash, patch.Namespace, comment, newhash, err)
return false
return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err)
}
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
patchId, err := repo.FindPatchId(newhash)
if err != nil {
return err
}
patch.PatchId = patchId
patch.NewHash = newhash
log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, comment)
return true
return nil
}
/*
func setNewCommitHashLoop(p *forgepb.Set) bool {
var done bool = true
for patch := range p.Patches.IterAll() {
setNewCommitHashLoop(patch)
}
return done
}
*/
func AddAllPatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
for patch := range pset.Patches.IterAll() {
comment := cleanSubject(patch.Comment)
@ -251,7 +231,7 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Set, full bool) {
continue
}
if patch.NewHash != "na" {
if patch.NewHash != "" {
log.Info("already applied patch", patch.Namespace, ": newhash:", patch.NewHash, "commithash:", patch.CommitHash, comment)
continue
}
@ -301,7 +281,7 @@ func findExpired() *forgepb.Patches {
continue
}
if patch.NewHash != "na" {
if patch.NewHash != "" {
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
continue

View File

@ -117,11 +117,8 @@ func applyPatchLabel(p *forgepb.Patch) string {
// log.Info("Could not figure out repo path", rn)
return ""
}
if p.NewHash == "na" {
return "git am"
}
if p.NewHash == "" {
return "new"
return "git am"
}
return "done"
}