raulcd commented on code in PR #14750:
URL: https://github.com/apache/arrow/pull/14750#discussion_r1037042971
##########
dev/merge_arrow_pr.py:
##########
@@ -187,71 +156,177 @@ def _filter_mainline_versions(self, versions):
return [x for x in versions if mainline_regex.match(x.name)]
- def resolve(self, fix_versions, comment):
+ def resolve(self, fix_version, comment):
fields = self.issue.fields
cur_status = fields.status.name
if cur_status == "Resolved" or cur_status == "Closed":
self.cmd.fail("JIRA issue %s already has status '%s'"
% (self.jira_id, cur_status))
- if DEBUG:
- print("JIRA issue %s untouched" % (self.jira_id))
- return
-
resolve = [x for x in self.jira_con.transitions(self.jira_id)
if x['name'] == "Resolve Issue"][0]
# ARROW-6915: do not overwrite existing fix versions corresponding to
# point releases
- fix_versions = list(fix_versions)
+ fix_versions = [v.raw for v in self.jira_con.project_versions(
+ self.project) if v.name == fix_version]
fix_version_names = set(x['name'] for x in fix_versions)
for version in self.current_fix_versions:
major, minor, patch = version.name.split('.')
if patch != '0' and version.name not in fix_version_names:
fix_versions.append(version.raw)
- self.jira_con.transition_issue(self.jira_id, resolve["id"],
- comment=comment,
- fixVersions=fix_versions)
-
- print("Successfully resolved %s!" % (self.jira_id))
+ if DEBUG:
+ print("JIRA issue %s untouched -> %s" %
+ (self.jira_id, [v["name"] for v in fix_versions]))
+ else:
+ self.jira_con.transition_issue(self.jira_id, resolve["id"],
+ comment=comment,
+ fixVersions=fix_versions)
+ print("Successfully resolved %s!" % (self.jira_id))
self.issue = self.jira_con.issue(self.jira_id)
self.show()
def show(self):
fields = self.issue.fields
- print(format_jira_output(self.jira_id, fields.status.name,
- fields.summary, fields.assignee,
- fields.components))
+ print(format_issue_output("jira", self.jira_id, fields.status.name,
+ fields.summary, fields.assignee,
+ fields.components))
-def format_jira_output(jira_id, status, summary, assignee, components):
- if assignee is None:
+class GitHubIssue(object):
+
+ def __init__(self, github_api, github_id, cmd):
+ self.github_api = github_api
+ self.github_id = github_id
+ self.cmd = cmd
+
+ try:
+ self.issue = self.github_api.get_issue_data(github_id)
+ except Exception as e:
+ self.cmd.fail("Github could not find %s\n%s" % (github_id, e))
+
+ def get_label(self, prefix):
+ prefix = f"{prefix}:"
+ return [
+ lbl["name"][len(prefix):].strip()
+ for lbl in self.issue["labels"] if lbl["name"].startswith(prefix)
+ ]
+
+ @property
+ def components(self):
+ return self.get_label("Component")
+
+ @property
+ def assignees(self):
+ return [a["login"] for a in self.issue["assignees"]]
+
+ @property
+ def current_fix_versions(self):
+ return self.issue.get("milestone", {}).get("title")
+
+ @property
+ def current_versions(self):
+ all_versions = self.github_api.get_milestones()
+
+ unreleased_versions = [x for x in all_versions if x["state"] == "open"]
+ unreleased_versions = [x["title"] for x in unreleased_versions]
+
+ return unreleased_versions
+
+ def resolve(self, fix_version, comment):
+ cur_status = self.issue["state"]
+
+ if cur_status == "closed":
+ self.cmd.fail("GitHub issue %s already has status '%s'"
+ % (self.github_id, cur_status))
+
+ if DEBUG:
+ print("GitHub issue %s untouched -> %s" %
+ (self.github_id, fix_version))
+ else:
+ self.github_api.assign_milestone(self.github_id, fix_version)
+ self.github_api.close_issue(self.github_id, comment)
Review Comment:
I've decided to validate whether the message `Closes: #XXX` is in the body
as expected from the dev_pr workflow:
https://github.com/apache/arrow/blob/master/.github/workflows/dev_pr/link.js#L85
otherwise we close the issue. That will close issues that might have been
created after an initial MINOR PR if we forgot to add the `Closes` or if the
description was manually modified, etcetera.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]