From 990236d18891a7976a2be9db8611a5e58dd956e5 Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Sun, 26 Jul 2015 11:08:12 -0400 Subject: [PATCH] fix for #29 which does not trigger flake8 for removed files that is accomplished by using --diff-filter parameter in git diff (taken from http://stackoverflow.com/questions/6879501/filter-git-diff-by-type-of-change) also this commit changes the log level from error to info when particular VCS is not found --- flake8diff/flake8.py | 2 +- flake8diff/vcs/git.py | 3 ++- flake8diff/vcs/hg.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flake8diff/flake8.py b/flake8diff/flake8.py index be436b2..7d5a4f8 100644 --- a/flake8diff/flake8.py +++ b/flake8diff/flake8.py @@ -129,7 +129,7 @@ def get_vcs(self): try: vcs = vcs(self.commits, self.options) except VCSNotInstalledError: - logger.error('Seems like {0} is not installed'.format(vcs.name)) + logger.info('Seems like {0} is not installed'.format(vcs.name)) else: if vcs.is_used() and vcs.check(): return vcs diff --git a/flake8diff/vcs/git.py b/flake8diff/vcs/git.py index a3ec5aa..db3ff4a 100644 --- a/flake8diff/vcs/git.py +++ b/flake8diff/vcs/git.py @@ -20,7 +20,7 @@ def get_vcs(self): """ Get git binary executable path """ - return _execute('which git', strict=True).strip() + return _execute('which git', strict=True, log_errors=False).strip() def is_used(self): """ @@ -64,6 +64,7 @@ def changed_files(self): self.vcs, "diff", "--name-only", + "--diff-filter=ACMRTUXB", ] + self.commits) return filter(self.filter_file, diff --git a/flake8diff/vcs/hg.py b/flake8diff/vcs/hg.py index b7b04d8..180071f 100644 --- a/flake8diff/vcs/hg.py +++ b/flake8diff/vcs/hg.py @@ -20,7 +20,7 @@ def get_vcs(self): """ Get git binary executable path """ - vcs = _execute('which hg', strict=True).strip() + vcs = _execute('which hg', strict=True, log_errors=False).strip() return vcs def is_used(self):