You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/06/25 05:35:54 UTC

[arrow] branch main updated: GH-36243: [Dev] Remove PR workflow label as part of merge (#36244)

This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5c2c7acba8 GH-36243: [Dev] Remove PR workflow label as part of merge (#36244)
5c2c7acba8 is described below

commit 5c2c7acba81b2c83e32b4e647ff38538406e3f92
Author: Raúl Cumplido <ra...@gmail.com>
AuthorDate: Sun Jun 25 07:35:47 2023 +0200

    GH-36243: [Dev] Remove PR workflow label as part of merge (#36244)
    
    ### Rationale for this change
    
    Those labels are unnecessary once they are merged. There was a conversation on Zulip about removing them in the past.
    
    ### What changes are included in this PR?
    
    Once we merge a PR we remove labels that starts with the PR workflow prefix `awaiting`.
    
    ### Are these changes tested?
    
    I have tested the code against an old testing PR I have here: https://github.com/apache/arrow/pull/35323
    The label was removed successfully.
    
    ### Are there any user-facing changes?
    
    No
    * Closes: #36243
    
    Authored-by: Raúl Cumplido <ra...@gmail.com>
    Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
 dev/merge_arrow_pr.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/dev/merge_arrow_pr.py b/dev/merge_arrow_pr.py
index 352befc328..90b2e9b034 100755
--- a/dev/merge_arrow_pr.py
+++ b/dev/merge_arrow_pr.py
@@ -418,11 +418,23 @@ class GitHubAPI(object):
         }
         response = requests.put(url, headers=self.headers, json=payload)
         result = response.json()
-        if response.status_code != 200 and 'merged' not in result:
+        if response.status_code == 200 and 'merged' in result:
+            self.clear_pr_state_labels(number)
+        else:
             result['merged'] = False
             result['message'] += f': {url}'
         return result
 
+    def clear_pr_state_labels(self, number):
+        url = f'{self.github_api}/issues/{number}/labels'
+        response = requests.get(url, headers=self.headers)
+        labels = response.json()
+        for label in labels:
+            # All PR workflow state labes starts with "awaiting"
+            if label['name'].startswith('awaiting'):
+                label_url = f"{url}/{label['name']}"
+                requests.delete(label_url, headers=self.headers)
+
 
 class CommandInput(object):
     """