diff options
Diffstat (limited to 'helperPatches.go')
| -rw-r--r-- | helperPatches.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/helperPatches.go b/helperPatches.go index 88c301a..7bee637 100644 --- a/helperPatches.go +++ b/helperPatches.go @@ -172,6 +172,32 @@ func findCommitBySubject(subject string) (string, error) { return "", fmt.Errorf("no commit found for subject: %s", subject) } +func isPatchIdApplied(patch *forgepb.Patch) error { + repo := me.forge.FindByGoPath(patch.Namespace) + if repo == nil { + return log.Errorf("could not find repo %s", patch.Namespace) + } + + comment := cleanSubject(patch.Comment) + + os.Chdir(repo.GetFullPath()) + newhash, err := findCommitBySubject(comment) + if err != nil { + return log.Errorf("patch: not found hash: %s %s %s %s %v", patch.CommitHash, patch.Namespace, comment, newhash, err) + } + + 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 nil +} + // returns true if PB changed func setNewCommitHash(patch *forgepb.Patch) error { repo := me.forge.FindByGoPath(patch.Namespace) |
