Commit 94bf8a18 by David Baumgold

Merge pull request #1522 from edx/db/fix-release-script

Fixes to release.py script
parents 5fb487a3 da49c353
...@@ -11,6 +11,7 @@ import re ...@@ -11,6 +11,7 @@ import re
from collections import OrderedDict from collections import OrderedDict
import textwrap import textwrap
IGNORED_EMAILS = set(("vagrant@precise32.(none)",))
JIRA_RE = re.compile(r"\b[A-Z]{2,}-\d+\b") JIRA_RE = re.compile(r"\b[A-Z]{2,}-\d+\b")
PROJECT_ROOT = path(__file__).abspath().dirname() PROJECT_ROOT = path(__file__).abspath().dirname()
repo = Repo(PROJECT_ROOT) repo = Repo(PROJECT_ROOT)
...@@ -57,7 +58,7 @@ def parse_ticket_references(text): ...@@ -57,7 +58,7 @@ def parse_ticket_references(text):
return JIRA_RE.findall(text) return JIRA_RE.findall(text)
def emails(from_commit, to_commit): def emails(commit_range):
""" """
Returns a set of all email addresses responsible for the commits between Returns a set of all email addresses responsible for the commits between
the two commit references. the two commit references.
...@@ -65,10 +66,11 @@ def emails(from_commit, to_commit): ...@@ -65,10 +66,11 @@ def emails(from_commit, to_commit):
# %ae prints the authored_by email for the commit # %ae prints the authored_by email for the commit
# %n prints a newline # %n prints a newline
# %ce prints the committed_by email for the commit # %ce prints the committed_by email for the commit
return set(git.log(from_commit, to_commit, format='%ae%n%ce').splitlines()) emails = set(git.log(commit_range, format='%ae%n%ce').splitlines())
return emails - IGNORED_EMAILS
def commits_by_email(from_commit, to_commit, include_merge=False): def commits_by_email(commit_range, include_merge=False):
""" """
Return a ordered dictionary of {email: commit_list} Return a ordered dictionary of {email: commit_list}
The dictionary is alphabetically ordered by email address The dictionary is alphabetically ordered by email address
...@@ -77,10 +79,9 @@ def commits_by_email(from_commit, to_commit, include_merge=False): ...@@ -77,10 +79,9 @@ def commits_by_email(from_commit, to_commit, include_merge=False):
kwargs = {} kwargs = {}
if not include_merge: if not include_merge:
kwargs["no-merges"] = True kwargs["no-merges"] = True
commit_range = "{0}..{1}".format(from_commit, to_commit)
data = OrderedDict() data = OrderedDict()
for email in sorted(emails(from_commit, to_commit)): for email in sorted(emails(commit_range)):
authored_commits = set(repo.iter_commits( authored_commits = set(repo.iter_commits(
commit_range, author=email, **kwargs commit_range, author=email, **kwargs
)) ))
...@@ -92,14 +93,14 @@ def commits_by_email(from_commit, to_commit, include_merge=False): ...@@ -92,14 +93,14 @@ def commits_by_email(from_commit, to_commit, include_merge=False):
return data return data
def generate_table(from_commit, to_commit, include_merge=False): def generate_table(commit_range, include_merge=False):
""" """
Return a string corresponding to a commit table to embed in Confluence Return a string corresponding to a commit table to embed in Confluence
""" """
header = "||Author||Summary||Commit||JIRA||Verified?||" header = "||Author||Summary||Commit||JIRA||Verified?||"
commit_link = "[commit|https://github.com/edx/edx-platform/commit/{sha}]" commit_link = "[commit|https://github.com/edx/edx-platform/commit/{sha}]"
rows = [header] rows = [header]
cbe = commits_by_email(from_commit, to_commit, include_merge) cbe = commits_by_email(commit_range, include_merge)
for email, commits in cbe.items(): for email, commits in cbe.items():
for i, commit in enumerate(commits): for i, commit in enumerate(commits):
rows.append("| {author} | {summary} | {commit} | {jira} | {verified} |".format( rows.append("| {author} | {summary} | {commit} | {jira} | {verified} |".format(
...@@ -112,7 +113,7 @@ def generate_table(from_commit, to_commit, include_merge=False): ...@@ -112,7 +113,7 @@ def generate_table(from_commit, to_commit, include_merge=False):
return "\n".join(rows) return "\n".join(rows)
def generate_email(from_commit, to_commit, release_date=None): def generate_email(commit_range, release_date=None):
""" """
Returns a string roughly approximating an email. Returns a string roughly approximating an email.
""" """
...@@ -128,8 +129,12 @@ def generate_email(from_commit, to_commit, release_date=None): ...@@ -128,8 +129,12 @@ def generate_email(from_commit, to_commit, release_date=None):
Please record your notes on https://edx-wiki.atlassian.net/wiki/display/ENG/Release+Page%3A+{date} Please record your notes on https://edx-wiki.atlassian.net/wiki/display/ENG/Release+Page%3A+{date}
and add any bugs found to the Release Candidate Bugs section. and add any bugs found to the Release Candidate Bugs section.
If you are a non-affiliated open-source contributor to edx-platform,
the edX employee who merged in your pull request will manually verify
your change(s), and you may disregard this message.
""".format( """.format(
emails=", ".join(sorted(emails(from_commit, to_commit))), emails=", ".join(sorted(emails(commit_range))),
date=release_date.isoformat(), date=release_date.isoformat(),
) )
return textwrap.dedent(email).strip() return textwrap.dedent(email).strip()
...@@ -141,13 +146,14 @@ def main(): ...@@ -141,13 +146,14 @@ def main():
if isinstance(args.date, basestring): if isinstance(args.date, basestring):
# user passed in a custom date, so we need to parse it # user passed in a custom date, so we need to parse it
args.date = parse_datestring(args.date).date() args.date = parse_datestring(args.date).date()
commit_range = "{0}..{1}".format(args.previous, args.current)
if args.table: if args.table:
print(generate_table(args.previous, args.current, include_merge=args.merge)) print(generate_table(commit_range, include_merge=args.merge))
return return
print("EMAIL:") print("EMAIL:")
print(generate_email(args.previous, args.current, release_date=args.date)) print(generate_email(commit_range, release_date=args.date))
print("\n") print("\n")
print("Wiki Table:") print("Wiki Table:")
print( print(
...@@ -155,7 +161,7 @@ def main(): ...@@ -155,7 +161,7 @@ def main():
"in your release wiki page" "in your release wiki page"
) )
print("\n") print("\n")
print(generate_table(args.previous, args.current, include_merge=args.merge)) print(generate_table(commit_range, include_merge=args.merge))
if __name__ == "__main__": if __name__ == "__main__":
main() main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment