This is an automated email from the ASF dual-hosted git repository.
ruifengz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 9e9d66b1c6e [SPARK-44944][INFRA] Auto grant contributor role to
first-time contributors
9e9d66b1c6e is described below
commit 9e9d66b1c6efe5f0c9c8f6300e5f7df620d2448b
Author: Kent Yao <[email protected]>
AuthorDate: Fri Aug 25 13:12:02 2023 +0800
[SPARK-44944][INFRA] Auto grant contributor role to first-time contributors
### What changes were proposed in this pull request?
This PR improves the experience while merging PR from first-time
contributors by creating their contributor role at the ASF Spark Jira side.
### Why are the changes needed?
First-time contributors can fail the merging progress as they are not
assignable to issues.
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
locally verified
```python
>>> 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
...
User 'liuxun' cannot be assigned, add to contributors role and try again?
(y/n): y
True
```
### Was this patch authored or co-authored using generative AI tooling?
no
Closes #42653 from yaooqinn/SPARK-44944.
Authored-by: Kent Yao <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
---
dev/merge_spark_pr.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py
index 0633ed41168..01851b185dd 100755
--- a/dev/merge_spark_pr.py
+++ b/dev/merge_spark_pr.py
@@ -394,7 +394,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
@@ -403,6 +418,12 @@ def choose_jira_assignee(issue, asf_jira):
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("SPARK", 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]