You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/07/07 14:58:07 UTC
[lucene-jira-archive] branch main updated: Check if the assignee account can be assigned on the repo (#18)
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git
The following commit(s) were added to refs/heads/main by this push:
new 23aaca5c Check if the assignee account can be assigned on the repo (#18)
23aaca5c is described below
commit 23aaca5ccb705c16c4719af99a187a27c466102b
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Thu Jul 7 23:58:03 2022 +0900
Check if the assignee account can be assigned on the repo (#18)
---
migration/src/github_issues_util.py | 11 +++++++++++
migration/src/import_github_issues.py | 4 ++++
2 files changed, 15 insertions(+)
diff --git a/migration/src/github_issues_util.py b/migration/src/github_issues_util.py
index 3bea2165..7cb17e6d 100644
--- a/migration/src/github_issues_util.py
+++ b/migration/src/github_issues_util.py
@@ -95,3 +95,14 @@ def get_import_status(token: str, url: str, logger: Logger) -> Optional[tuple[st
logger.error(f"Failed to get import status for {url}; status code={res.status_code}, message={res.text}")
return None
return (res.json().get("status"), res.json().get("issue_url", ""), res.json().get("errors", []))
+
+
+def check_if_can_be_assigned(token: str, repo: str, assignee: str, logger: Logger) -> bool:
+ url = GITHUB_API_BASE + f"/repos/{repo}/assignees/{assignee}"
+ headers = {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json"}
+ res = requests.get(url, headers=headers)
+ if res.status_code == 204:
+ return True
+ else:
+ logger.warning(f"Assignee {assignee} cannot be assigned; status code={res.status_code}, message={res.text}")
+ return False
diff --git a/migration/src/import_github_issues.py b/migration/src/import_github_issues.py
index eddb1a1f..80a65070 100644
--- a/migration/src/import_github_issues.py
+++ b/migration/src/import_github_issues.py
@@ -30,6 +30,10 @@ def import_issue_with_comments(num: int, data_dir: Path, token: str, repo: str)
return None
with open(data_file) as fp:
issue_data = json.load(fp)
+ assignee = issue_data["issue"].get("assignee")
+ if assignee and not check_if_can_be_assigned(token, repo, assignee, logger):
+ # this field should be removed; otherwise an error occurs.
+ del issue_data["issue"]["assignee"]
url = import_issue(token, repo, issue_data, logger)
(status, issue_url, errors) = ("pending", "", [])
while not status or status == "pending":