From 96122fc9a9ca434507a1882d2481f41fb7b0ffab Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 6 May 2014 09:34:12 -0400 Subject: [PATCH] Warn and continue for missing merge commits --- scripts/release.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 777f823dd5..416afc8412 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -75,6 +75,13 @@ def parse_ticket_references(text): return JIRA_RE.findall(text) +class DoesNotExist(Exception): + def __init__(self, message, commit, branch): + self.message = message + self.commit = commit + self.branch = branch + + def get_merge_commit(commit, branch="master"): """ Given a commit that was merged into the given branch, return the merge commit @@ -89,9 +96,11 @@ def get_merge_commit(commit, branch="master"): for commit_hash in reversed(ancestry_paths): if commit_hash in both: return repo.commit(commit_hash) - raise ValueError("No merge commit for {commit} in {branch}!".format( + # no merge commit! + msg = "No merge commit for {commit} in {branch}!".format( commit=commit, branch=branch, - )) + ) + raise DoesNotExist(msg, commit, branch) def get_pr_info(num): @@ -140,8 +149,19 @@ def prs_by_email(start_ref, end_ref): for pr_num in get_merged_prs(start_ref, end_ref): ref = "refs/remotes/edx/pr/{num}".format(num=pr_num) branch = SymbolicReference(repo, ref) - merge = get_merge_commit(branch.commit, end_ref) - unordered_data[merge.author.email].add((pr_num, merge)) + try: + merge = get_merge_commit(branch.commit, end_ref) + except DoesNotExist as err: + print( + "Warning: could not find merge commit for {commit}. The pull " + "request containing this commit will not be included in the " + "table.".format( + commit=err.commit + ), + file=sys.stderr, + ) + else: + unordered_data[merge.author.email].add((pr_num, merge)) ordered_data = OrderedDict() for email in sorted(unordered_data.keys()):