diff options
| author | Jeff Carr <[email protected]> | 2025-09-05 12:53:05 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-05 12:53:05 -0500 |
| commit | e639f7d7b7930185aa319a91317087015887d75e (patch) | |
| tree | 27228d32cd811adb6ead90b5db93fa7b725c1284 /helperPatches.go | |
| parent | 790c48e0d0ef2fde8583820b8ab834449bf00ac0 (diff) | |
set patch NewHash
Diffstat (limited to 'helperPatches.go')
| -rw-r--r-- | helperPatches.go | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/helperPatches.go b/helperPatches.go index bb19a39..2d2d90c 100644 --- a/helperPatches.go +++ b/helperPatches.go @@ -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() { - // parts := strings.Fields(patch.Comment) +// 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 - } + repo := me.forge.FindByGoPath(patch.Namespace) + if repo == nil { + log.Info("could not find repo", patch.Namespace) + return false + } - comment := cleanSubject(patch.Comment) + comment := cleanSubject(patch.Comment) - if patch.NewHash != "na" { - log.Info("patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment) - continue - } - 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 - } - patch.NewHash = newhash - log.Info("patch: found hash:", patch.CommitHash, newhash, patch.Namespace, 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 + } + 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() { |
