This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/main by this push:
new 55ec5e62a ORC-1509: Auto grant contributor role to first-time
contributors
55ec5e62a is described below
commit 55ec5e62ad3e92715e911844a5159f69270f8469
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Sat Oct 7 15:35:42 2023 -0700
ORC-1509: Auto grant contributor role to first-time contributors
### What changes were proposed in this pull request?
This PR aims to grant 'Apache ORC Contributor' role to the first-time
contributors.
### Why are the changes needed?
To provide more convenient ways to the Apache ORC committers
### How was this patch tested?
Manual.
Closes #1621 from dongjoon-hyun/ORC-1509.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
dev/merge_orc_pr.py | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/dev/merge_orc_pr.py b/dev/merge_orc_pr.py
index 6795701fa..12062c166 100755
--- a/dev/merge_orc_pr.py
+++ b/dev/merge_orc_pr.py
@@ -373,7 +373,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)
- asf_jira.assign_issue(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
@@ -382,6 +397,25 @@ 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("ORC", 10010)
+ role.add_user(user)
+ print("Successfully added user '%s' to contributors role" % user)
+
+
+def assign_issue(client: jira.client.JIRA, issue: int, assignee: str) -> bool:
+ """
+ Assign an issue to a user, which is a shorthand for
jira.client.JIRA.assign_issue.
+ The original one has an issue that it will search users again and only
choose the assignee
+ from 20 candidates. If it's unmatched, it picks the head blindly. In our
case, the assignee
+ is already resolved.
+ """
+ url = getattr(client, "_get_latest_url")(f"issue/{issue}/assignee")
+ payload = {"name": assignee}
+ getattr(client, "_session").put(url, data=json.dumps(payload))
+ return True
+
+
def resolve_jira_issues(title, merge_branches, comment):
jira_ids = re.findall("ORC-[0-9]{4,5}", title)