Deal with <2 commits for find_merge_base

This commit is contained in:
jan 2019-03-31 12:15:50 -07:00
parent 668efd063a
commit 3665d1db88

View File

@ -109,6 +109,12 @@ def find_merge_base(commits: List[str], cwd: str=None) -> str:
"""
Find the "best common ancestor" commit.
"""
if len(commits) == 0:
raise Exception('Called find_merge_base with no commits!')
if len(commits) == 1:
return commits[0]
base = _run(['git', 'merge-base', *commits], cwd=cwd)
return base