From 3665d1db889d5811781c809a2fd75005507e9c11 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 31 Mar 2019 12:15:50 -0700 Subject: [PATCH] Deal with <2 commits for find_merge_base --- lethe.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lethe.py b/lethe.py index 71e700c..5915a64 100755 --- a/lethe.py +++ b/lethe.py @@ -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