summaryrefslogtreecommitdiff
path: root/helperPatches.go
diff options
context:
space:
mode:
Diffstat (limited to 'helperPatches.go')
-rw-r--r--helperPatches.go62
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() {