-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-11804: [Developer] Offer to create JIRA issue #9598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |||||
| import sys | ||||||
| import requests | ||||||
| import getpass | ||||||
| import json | ||||||
|
|
||||||
| from six.moves import input | ||||||
| import six | ||||||
|
|
@@ -135,6 +136,14 @@ def fix_version_from_branch(branch, versions): | |||||
| for project in SUPPORTED_PROJECTS] | ||||||
|
|
||||||
|
|
||||||
| def get_jira_id(title): | ||||||
| for project, regex in PR_TITLE_REGEXEN: | ||||||
| m = regex.search(title) | ||||||
| if m: | ||||||
| return (m.group(1), project) | ||||||
| return (None, None) | ||||||
|
|
||||||
|
|
||||||
| class JiraIssue(object): | ||||||
|
|
||||||
| def __init__(self, jira_con, jira_id, project, cmd): | ||||||
|
|
@@ -263,6 +272,21 @@ def get_pr_data(self, number): | |||||
| return get_json("%s/pulls/%s" % (self.github_api, number), | ||||||
| headers=self.headers) | ||||||
|
|
||||||
| def update_pr_title(self, number, title): | ||||||
| if not self.headers: | ||||||
| msg = ("Can not update PR {} title to '{}'. " + | ||||||
| "ARROW_GITHUB_API_TOKEN environment not set").format( | ||||||
| number, title | ||||||
| ) | ||||||
| raise Exception(msg) | ||||||
|
|
||||||
| # note need to use the issues URL to update | ||||||
| url = "%s/issues/%s" % (self.github_api, number) | ||||||
| data = json.dumps({'title': title}) | ||||||
| resp = requests.patch(url, data=data, headers=self.headers) | ||||||
| resp.raise_for_status() | ||||||
| return resp.json() | ||||||
|
|
||||||
|
|
||||||
| class CommandInput(object): | ||||||
| """ | ||||||
|
|
@@ -292,12 +316,12 @@ def continue_maybe(self, prompt): | |||||
|
|
||||||
| class PullRequest(object): | ||||||
|
|
||||||
| def __init__(self, cmd, github_api, git_remote, jira_con, number): | ||||||
| def __init__(self, cmd, pr_data, git_remote, jira_con, number): | ||||||
| self.cmd = cmd | ||||||
| self.git_remote = git_remote | ||||||
| self.con = jira_con | ||||||
| self.number = number | ||||||
| self._pr_data = github_api.get_pr_data(number) | ||||||
| self._pr_data = pr_data | ||||||
| try: | ||||||
| self.url = self._pr_data["url"] | ||||||
| self.title = self._pr_data["title"] | ||||||
|
|
@@ -327,12 +351,7 @@ def is_mergeable(self): | |||||
| return bool(self._pr_data["mergeable"]) | ||||||
|
|
||||||
| def _get_jira(self): | ||||||
| jira_id = None | ||||||
| for project, regex in PR_TITLE_REGEXEN: | ||||||
| m = regex.search(self.title) | ||||||
| if m: | ||||||
| jira_id = m.group(1) | ||||||
| break | ||||||
| (jira_id, project) = get_jira_id(self.title) | ||||||
|
|
||||||
| if jira_id is None: | ||||||
| options = ' or '.join('{0}-XXX'.format(project) | ||||||
|
|
@@ -370,7 +389,7 @@ def merge(self): | |||||
| had_conflicts = True | ||||||
|
|
||||||
| commit_authors = run_cmd(['git', 'log', 'HEAD..%s' % pr_branch_name, | ||||||
| '--pretty=format:%an <%ae>']).split("\n") | ||||||
| '--pretty=format:%an <%ae>']).split("\n") | ||||||
| distinct_authors = sorted(set(commit_authors), | ||||||
| key=lambda x: commit_authors.count(x), | ||||||
| reverse=True) | ||||||
|
|
@@ -551,6 +570,86 @@ def get_pr_num(): | |||||
| return input("Which pull request would you like to merge? (e.g. 34): ") | ||||||
|
|
||||||
|
|
||||||
| _JIRA_COMPONENT_REGEX = re.compile(r'(\[[^\]]*\])+') | ||||||
|
|
||||||
| # Maps PR title prefixes to JIRA components | ||||||
|
||||||
| PR_COMPONENTS_TO_JIRA_COMPONENTS = { | ||||||
| '[Rust]': 'Rust', | ||||||
| '[Rust][DataFusion]': 'Rust - DataFusion', | ||||||
| '[C++]': 'C++', | ||||||
| '[R]': 'R', | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| # Return the best matching JIRA component from a PR title, if any | ||||||
| # "[Rust] Fix something" --> Rust | ||||||
| # "[Rust][DataFusion] Fix" --> Rust - DataFusion | ||||||
| # "[CPP] Fix " --> "C++" | ||||||
|
||||||
| # "[CPP] Fix " --> "C++" | |
| # "[C++] Fix " --> "C++" |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate word: returns returns
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, f-strings could be used in most of the places where format is currently being used.
Before:
>>> title = "Hello"
>>> summary = "{}".format(title)
>>> summary
'Hello'
After:
>>> title = "Hello"
>>> summary = f"{title}"
>>> summary
'Hello'
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using the pull request description as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale to add a note on provenance was:
- I felt for auto generated tickets it was unlikely the author would keep JIRA and the Pull Request synced, and the PR was likely to be the source of truth
- Hint to anyone reading the JIRA issue they should look at the PR if they wanted to know the current status of the change.
I am happy to remove the auto-link if that is the consensus
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
The bracketing style isn't totally consistent in this file, but it appears to be either:
issue = jira_con.create_issue(project='ARROW',
summary=summary,
description=description,
issuetype={'name': 'Bug'},
components=components)
or:
issue = jira_con.create_issue(
project='ARROW',
summary=summary,
description=description,
issuetype={'name': 'Bug'},
components=components,
)
But not:
issue = jira_con.create_issue(project='ARROW',
summary=summary,
description=description,
issuetype={'name': 'Bug'},
components=components,
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Can not/Cannot/