Berker Peksag added the comment:

Thanks for the feedback. Here's a patch that updates 'stage' and 'keywords' 
fields. This patch updates the detector. I'll upload another one for the 
webhook.

I'll commit it when I get a code review, thanks!

_______________________________________________________
PSF Meta Tracker <metatrac...@psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue615>
_______________________________________________________
diff --git a/detectors/setresolved.py b/detectors/issuestates.py
rename from detectors/setresolved.py
rename to detectors/issuestates.py
--- a/detectors/setresolved.py
+++ b/detectors/issuestates.py
@@ -1,16 +1,33 @@
 """
-A detector that sets the 'stage' field to 'resolved' when an issue is closed.
+* Sets the 'stage' field to 'resolved' when an issue is closed.
+* Sets the 'stage' field to 'patch review' and adds 'patch' to the 'keywords' 
field.
 """
 
 
-def setresolved(db, cl, nodeid, newvalues):
+def issuestates(db, cl, nodeid, newvalues):
     status_change = newvalues.get('status')
     status_close = status_change and status_change == 
db.status.lookup('closed')
 
     if status_close:
         if newvalues.get('stage') is None:
             newvalues['stage'] = db.stage.lookup('resolved')
 
+    is_open = cl.get(nodeid, 'status') == db.status.lookup('open')
+    patch_keyword = db.keyword.lookup('patch')
+    old_keywords = cl.get(nodeid, 'keywords')
+    new_keywords = newvalues.get('keywords', [])
+    old_prs = cl.get(nodeid, 'pull_requests')
+    new_prs = newvalues.get('pull_requests', [])
+    pr_change = len(new_prs) > len(old_prs)
+    needs_change = is_open and pr_change and newvalues.get('stage') != 
db.stage.lookup('patch review')
+    if needs_change:
+        newvalues['stage'] = db.stage.lookup('patch review')
+        if patch_keyword not in new_keywords and patch_keyword not in 
old_keywords:
+            set_new_keywords = old_keywords[:]
+            set_new_keywords.extend(new_keywords)
+            set_new_keywords.append(patch_keyword)
+            newvalues['keywords'] = set_new_keywords
+
 
 def init(db):
-    db.issue.audit('set', setresolved)
+    db.issue.audit('set', issuestates)
_______________________________________________
Tracker-discuss mailing list
Tracker-discuss@python.org
https://mail.python.org/mailman/listinfo/tracker-discuss
Code of Conduct: https://www.python.org/psf/codeofconduct/

Reply via email to