This is an automated email from the ASF dual-hosted git repository.
zhouky pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new 2b657c524 [CELEBORN-918][INFRA] Auto Assign First-time contributor
with Contributors role
2b657c524 is described below
commit 2b657c5243b73a0e41e853291b8b46fb36873348
Author: Kent Yao <[email protected]>
AuthorDate: Sat Aug 26 16:50:31 2023 +0800
[CELEBORN-918][INFRA] Auto Assign First-time contributor with Contributors
role
### What changes were proposed in this pull request?
As an incubating project, first-time contributorsā welcome is routine. This
PR adds automation for granting Contributors role to them to make them a
assignable for issues
### Why are the changes needed?
GitHub - JIRA integration
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
tested at apache/spark project, and
```python
>>> asf_jira.project_roles("CELEBORN")
{'Developers': {'id': '10050', 'url':
'https://issues.apache.org/jira/rest/api/2/project/12324920/role/10050'},
'Contributors': {'id': '10010', 'url':
'https://issues.apache.org/jira/rest/api/2/project/12324920/role/10010'},
'PMC': {'id': '10011', 'url':
'https://issues.apache.org/jira/rest/api/2/project/12324920/role/10011'},
'Committers': {'id': '10001', 'url':
'https://issues.apache.org/jira/rest/api/2/project/12324920/role/10001'},
'Administrators': {'id': '10002', 'url': 'https:/ [...]
```
Closes #1839 from yaooqinn/CELEBORN-918.
Authored-by: Kent Yao <[email protected]>
Signed-off-by: zky.zhoukeyong <[email protected]>
---
dev/merge_pr.py | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/dev/merge_pr.py b/dev/merge_pr.py
index b613816c6..5ac9cc876 100755
--- a/dev/merge_pr.py
+++ b/dev/merge_pr.py
@@ -393,7 +393,22 @@ def choose_jira_assignee(issue, asf_jira):
except BaseException:
# assume it's a user id, and try to assign (might fail, we
just prompt again)
assignee = asf_jira.user(raw_assignee)
- assign_issue(asf_jira, issue.key, assignee.name)
+ try:
+ assign_issue(asf_jira, issue.key, assignee.name)
+ except Exception as e:
+ if (
+ e.__class__.__name__ == "JIRAError"
+ and ("'%s' cannot be assigned" % assignee.name)
+ in getattr(e, "response").text
+ ):
+ continue_maybe(
+ "User '%s' cannot be assigned, add to contributors
role and try again?"
+ % assignee.name
+ )
+ grant_contributor_role(assignee.name, asf_jira)
+ assign_issue(asf_jira, issue.key, assignee.name)
+ else:
+ raise e
return assignee
except KeyboardInterrupt:
raise
@@ -401,6 +416,11 @@ def choose_jira_assignee(issue, asf_jira):
traceback.print_exc()
print("Error assigning JIRA, try again (or leave blank and fix
manually)")
+def grant_contributor_role(user: str, asf_jira):
+ role = asf_jira.project_role("CELEBORN", 10010)
+ role.add_user(user)
+ print("Successfully added user '%s' to contributors role" % user)
+
def assign_issue(client, issue: int, assignee: str) -> bool:
"""
Assign an issue to a user, which is a shorthand for
jira.client.JIRA.assign_issue.