@@ -51,6 +51,9 @@ def handle_custom_labels(api, event):
5151
5252
5353def update_rebase_status (api , payload ):
54+ if "pull_request" not in payload :
55+ return
56+
5457 mergeable = payload ['pull_request' ]['mergeable' ]
5558
5659 # If mergeable is null, the data wasn't available yet.
@@ -64,23 +67,33 @@ def update_rebase_status(api, payload):
6467 api .add_label (NEED_REBASE )
6568
6669
70+ def is_draft_pr (payload ):
71+ return "pull_request" in payload and payload ["pull_request" ]["draft" ] == True
72+
73+
6774class StatusUpdateHandler (EventHandler ):
6875 def on_pr_opened (self , api , payload ):
76+ if is_draft_pr (payload ):
77+ return
78+
6979 labels = api .get_labels ()
7080 if AWAITING_REVIEW not in labels :
7181 api .add_label (AWAITING_REVIEW )
7282 update_rebase_status (api , payload )
7383 handle_custom_labels (api , 'opened' )
7484
7585 def on_pr_updated (self , api , payload ):
86+ if is_draft_pr (payload ):
87+ return
88+
7689 clear_pr_labels (api )
7790 api .add_label (AWAITING_REVIEW )
7891 update_rebase_status (api , payload )
7992 handle_custom_labels (api , 'updated' )
8093
8194 def on_pr_closed (self , api , payload ):
8295 handle_custom_labels (api , 'closed' )
83- if "pull_request" in payload and payload ['pull_request' ]['merged' ]:
96+ if "pull_request" in payload and payload ['pull_request' ]['merged' ] == True :
8497 api .remove_label (AWAITING_MERGE )
8598 handle_custom_labels (api , 'merged' )
8699
0 commit comments