Github user texasmichelle commented on a diff in the pull request:
https://github.com/apache/spark/pull/5149#discussion_r28632970
--- Diff: dev/merge_spark_pr.py ---
@@ -286,68 +281,137 @@ def resolve_jira_issues(title, merge_branches,
comment):
resolve_jira_issue(merge_branches, comment, jira_id)
-branches = get_json("%s/branches" % GITHUB_API_BASE)
-branch_names = filter(lambda x: x.startswith("branch-"), [x['name'] for x
in branches])
-# Assumes branch names can be sorted lexicographically
-latest_branch = sorted(branch_names, reverse=True)[0]
-
-pr_num = raw_input("Which pull request would you like to merge? (e.g. 34):
")
-pr = get_json("%s/pulls/%s" % (GITHUB_API_BASE, pr_num))
-pr_events = get_json("%s/issues/%s/events" % (GITHUB_API_BASE, pr_num))
-
-url = pr["url"]
-title = pr["title"]
-body = pr["body"]
-target_ref = pr["base"]["ref"]
-user_login = pr["user"]["login"]
-base_ref = pr["head"]["ref"]
-pr_repo_desc = "%s/%s" % (user_login, base_ref)
-
-# Merged pull requests don't appear as merged in the GitHub API;
-# Instead, they're closed by asfgit.
-merge_commits = \
- [e for e in pr_events if e["actor"]["login"] == "asfgit" and
e["event"] == "closed"]
-
-if merge_commits:
- merge_hash = merge_commits[0]["commit_id"]
- message = get_json("%s/commits/%s" % (GITHUB_API_BASE,
merge_hash))["commit"]["message"]
-
- print "Pull request %s has already been merged, assuming you want to
backport" % pr_num
- commit_is_downloaded = run_cmd(['git', 'rev-parse', '--quiet',
'--verify',
+def standardize_jira_ref(text):
+ """
+ Standardize the [MODULE] SPARK-XXXXX prefix
+ Converts "[SPARK-XXX][mllib] Issue", "[MLLib] SPARK-XXX. Issue" or
"SPARK XXX [MLLIB]: Issue" to "[MLLIB] SPARK-XXX: Issue"
+
+ >>> standardize_jira_ref("[SPARK-5821] [SQL] ParquetRelation2 CTAS
should check if delete is successful")
+ '[SQL] SPARK-5821: ParquetRelation2 CTAS should check if delete is
successful'
+ >>> standardize_jira_ref("[SPARK-4123][Project Infra][WIP]: Show new
dependencies added in pull requests")
+ '[PROJECT INFRA] [WIP] SPARK-4123: Show new dependencies added in pull
requests'
+ >>> standardize_jira_ref("[MLlib] Spark 5954: Top by key")
+ '[MLLIB] SPARK-5954: Top by key'
+ """
+ #If the string is compliant, no need to process any further
+ if (re.search(r'\[[A-Z0-9_]+\] SPARK-[0-9]{3,5}: \S+', text)):
+ return text
+
+ # Extract JIRA ref(s):
+ jira_refs = deque()
+ pattern = re.compile(r'(SPARK[-\s]*[0-9]{3,5})', re.IGNORECASE)
+ while (pattern.search(text) is not None):
+ ref = pattern.search(text).groups()[0]
+ # Replace any whitespace with a dash & convert to uppercase
+ jira_refs.append(re.sub(r'\s+', '-', ref.upper()))
+ text = text.replace(ref, '')
+
+ # Extract spark component(s):
+ components = deque()
+ # Look for alphanumeric chars, spaces, and/or commas
+ pattern = re.compile(r'(\[[\w\s,]+\])', re.IGNORECASE)
+ while (pattern.search(text) is not None):
+ component = pattern.search(text).groups()[0]
+ # Convert to uppercase
+ components.append(component.upper())
+ text = text.replace(component, '')
+
+ # Cleanup remaining symbols:
+ pattern = re.compile(r'^\W+(.*)', re.IGNORECASE)
+ if (pattern.search(text) is not None):
+ text = pattern.search(text).groups()[0]
+
+ # Assemble full text (module(s), JIRA ref(s), remaining text)
+ if (len(components) < 1):
+ components = ""
+ component_text = ' '.join(components).strip()
+ if (len(jira_refs) < 1):
+ jira_ref_text = ""
+ jira_ref_text = ' '.join(jira_refs).strip()
+
+ if (len(jira_ref_text) < 1 and len(component_text) < 1):
+ clean_text = text.strip()
+ elif (len(jira_ref_text) < 1):
+ clean_text = component_text + ' ' + text.strip()
+ elif (len(component_text) < 1):
+ clean_text = jira_ref_text + ': ' + text.strip()
+ else:
+ clean_text = component_text + ' ' + jira_ref_text + ': ' +
text.strip()
+
+ return clean_text
+
+def main():
+ os.chdir(SPARK_HOME)
--- End diff --
Right - everything inside main() was previously containerless. All
statements not part of a function were moved into main() and doctest execution
was added at the end. The only new code is the function standardize_jira_ref(),
along with its reference on line 357.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]