From 6c395673e29fdf446111f57bdfe215ac4f9760db Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Mon, 5 May 2014 21:34:21 +0200 Subject: [PATCH] Do not overwrite Git pre-commit hook; closes #149 --- CHANGES.rst | 2 +- flake8/hooks.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 591d870..0079324 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,7 @@ CHANGES - New option ``doctests`` to run Pyflakes checks on doctests too - New option ``jobs`` to launch multiple jobs in parallel -- Fix Git and Mercurial hooks, issues #88, #133 and #148 +- Fix Git and Mercurial hooks: issues #88, #133, #148 and #149 - Fix crashes with Python 3.4 by upgrading dependencies - Fix traceback when running tests with Python 2.6 - Fix the setuptools command ``python setup.py flake8`` to read diff --git a/flake8/hooks.py b/flake8/hooks.py index 289b66f..9542279 100644 --- a/flake8/hooks.py +++ b/flake8/hooks.py @@ -228,6 +228,8 @@ def install_hook(): status = 0 if 'git' in vcs: + if os.path.exists(vcs): + sys.exit('Error: hook already exists (%s)' % vcs) with open(vcs, 'w') as fd: fd.write(git_hook_file) # rwxr--r--