Skip to content

Commit

Permalink
GH-36243: [Dev] Remove PR workflow label as part of merge (#36244)
Browse files Browse the repository at this point in the history
### 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: #35323
The label was removed successfully.

### Are there any user-facing changes?

No
* Closes: #36243

Authored-by: Raúl Cumplido <raulcumplido@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
raulcd committed Jun 25, 2023
1 parent 10eedbe commit 5c2c7ac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dev/merge_arrow_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,23 @@ def merge_pr(self, number, commit_title, commit_message):
}
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):
"""
Expand Down

0 comments on commit 5c2c7ac

Please sign in to comment.