Commit 96122fc9 by David Baumgold

Warn and continue for missing merge commits

parent ee33a12d
...@@ -75,6 +75,13 @@ def parse_ticket_references(text): ...@@ -75,6 +75,13 @@ def parse_ticket_references(text):
return JIRA_RE.findall(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"): def get_merge_commit(commit, branch="master"):
""" """
Given a commit that was merged into the given branch, return the merge commit 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"): ...@@ -89,9 +96,11 @@ def get_merge_commit(commit, branch="master"):
for commit_hash in reversed(ancestry_paths): for commit_hash in reversed(ancestry_paths):
if commit_hash in both: if commit_hash in both:
return repo.commit(commit_hash) 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, commit=commit, branch=branch,
)) )
raise DoesNotExist(msg, commit, branch)
def get_pr_info(num): def get_pr_info(num):
...@@ -140,8 +149,19 @@ def prs_by_email(start_ref, end_ref): ...@@ -140,8 +149,19 @@ def prs_by_email(start_ref, end_ref):
for pr_num in get_merged_prs(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) ref = "refs/remotes/edx/pr/{num}".format(num=pr_num)
branch = SymbolicReference(repo, ref) branch = SymbolicReference(repo, ref)
merge = get_merge_commit(branch.commit, end_ref) try:
unordered_data[merge.author.email].add((pr_num, merge)) 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() ordered_data = OrderedDict()
for email in sorted(unordered_data.keys()): for email in sorted(unordered_data.keys()):
......
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