Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Return early when no merge base commit
  • Loading branch information
saschanaz committed Jun 21, 2020
1 parent 90449ae commit 1d2e618
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions python/tidy/servo_tidy/tidy.py
Expand Up @@ -143,12 +143,7 @@ def __init__(self, directory, only_changed_files=False, exclude_dirs=[], progres
self.excluded = exclude_dirs
self.generator = self._filter_excluded() if exclude_dirs else self._default_walk()
if only_changed_files:
try:
# Fall back if git doesn't work
self.generator = self._git_changed_files()
except subprocess.CalledProcessError:
pass

self.generator = self._git_changed_files()
if progress:
self.generator = progress_wrapper(self.generator)

Expand All @@ -160,6 +155,9 @@ def _default_walk(self):
def _git_changed_files(self):
args = ["git", "log", "-n1", "--merges", "--format=%H"]
last_merge = subprocess.check_output(args, universal_newlines=True).strip()
if not last_merge:
return

args = ["git", "diff", "--name-only", last_merge, self.directory]
file_list = normilize_paths(subprocess.check_output(args, universal_newlines=True).splitlines())

Expand Down

0 comments on commit 1d2e618

Please sign in to comment.