Commit graph

52 commits

Author SHA1 Message Date
Ian Lee
1db863e60a Updated package to use pycodestyle
This change was originally triggered by @gvanrossum requeesting
that pep8 (the tool) be renamed to avoid confusion with PEP-8
the document. This request is tracked at:

https://github.com/PyCQA/pycodestyle/issues/466
2016-05-31 11:02:09 -07:00
Ian Cordasco
533d222f52 Correct usage config_file StyleGuide parameter
Previously, we passed the location for our user config file to the
StyleGuide. This was intended to be a way to tell pep8's StyleGuide
to use that as a user config file, but instead that became the default
for the --config command-line option. This caused that to have higher
priority than the project configuration file.

Closes #122
2016-02-17 20:57:24 -06:00
Ian Cordasco
fa1105aaac Isolate the commands that raise OSError
Right now, running the git and hg commands could easily raise an
OSError. Let's only catch it in those cases and then use else to
install hooks when those are successful. Otherwise, pass on to the next
supported VCS
2015-12-17 08:35:50 -06:00
adammhaile
4da31aa521 Fix checking for repo dir without git/hg 2015-12-16 22:40:57 -05:00
Ian Cordasco
12fab2f8ad Change the git-hook ignore default to None
When ignore is an empty string, it will apparently not run any checks at
all. Using None as the default ensures that it does run the appropriate
checks.

Closes #52
2015-04-05 23:01:44 -05:00
Ian Cordasco
0e2b873c38 Add compatibility layer for Python 2.6
os.path.relpath on Python 2.6 returns slightly different output than it
does on 2.7. Rather than try to write tests around the behaviour, it
makes sense to have a common relpath function that behaves the same on
every version.
2015-03-06 23:43:36 -06:00
Ian Cordasco
7ab30a747f Merge branch 'local/pr/2'
Conflicts:
	flake8/hooks.py
2015-03-06 23:26:44 -06:00
Ian Cordasco
c084211e9e Merge remote-tracking branch 'origin/gh/2' 2015-03-06 23:04:49 -06:00
Ian Cordasco
84c8dd5e8d Simplify @mpenkov's fix for exclude in git hooks
The simpler fix is to ensure that the filename isn't the full path to
the temporary file before we check to see if it should be excluded or if
it should even match.

This also fixes a bug I found while testing the pull request in which no
files are checked.
2015-03-06 23:01:30 -06:00
Ian Cordasco
54946334db WIP 2015-03-06 19:47:55 -06:00
Ian Cordasco
ba344c8ded Refactor some bits of flake8.hooks 2015-02-22 22:29:13 -06:00
Oleg Broytman
d03b526913 Use git config before os.environ
Get parameter's value using git config before trying os.environ.
2015-02-16 07:32:17 +03:00
Oleg Broytman
4d9a88298b Minor refactoring 2015-02-16 06:09:43 +03:00
Michael Penkov
de9fd7d6a2 Adding unit tests for fix in 218949a 2015-02-07 16:33:35 +09:00
Michael Penkov
218949a3aa Correctly handle exclude patterns in git_hook 2014-11-11 21:15:58 +09:00
Chris Buccella
c0dd7c870c Honor file pattern matching for git hook
In a config file, a user can use the "filename" option to specify
a pattern for matching filenames. The git hook effectively ignores
this and only checks files ending in '.py'
2014-09-23 00:54:39 -04:00
Florent Xicluna
6c395673e2 Do not overwrite Git pre-commit hook; closes #149 2014-05-05 21:34:21 +02:00
Florent Xicluna
d67491a104 Use write-only mode 'w' instead of 'w+' for writing hooks 2014-05-05 21:26:37 +02:00
Florent Xicluna
1ea9f12b18 Assume UTF-8 when decoding hg or git output; closes #148 2014-05-05 21:01:05 +02:00
Florent Xicluna
89f0800682 Merged in fr710/flake8 (pull request #41)
Fix Git and Mercurial hooks if no config files are present
2014-03-30 22:15:19 +02:00
Florian Rathgeber
f678e5daee Minor hg hook refactoring 2014-03-23 18:52:35 +00:00
Florian Rathgeber
b049912317 Pass current directory as paths to pep8 StyleGuide
Instead of setting parse_argv to True, which fails if no config files
are present, we pass the current directory as the paths keyword
argument when creating the pep8 StyleGuide. This causes pep8 to parse
local config files as expected and works also if none are present.

Requires pep8 68d72a5d or newer.
2014-03-23 18:52:00 +00:00
Florian Rathgeber
39e60d4254 Default hg ignore config to empty instead of None
Setting it to None is interpreted as the string 'None', which does the
wrong thing. Setting it to the empty string gives the right behaviour
and allows overriding in config files.
2014-03-23 18:47:21 +00:00
Florian Rathgeber
45c7138907 Disable mercurial demandimport in _pyflakes module
Disabling in hooks is too late since mercurial already imports
_pyflakes before.

Fixes #88
2014-03-23 18:35:08 +00:00
Florian Rathgeber
b4d786a393 Git and Mercurial hooks respect FLAKE8_LAZY 2013-10-26 14:06:10 -05:00
Florian Rathgeber
016ec97514 Git and Mercurial hooks respect FLAKE8_IGNORE 2013-10-26 14:04:44 -05:00
Florian Rathgeber
ac55c9d419 Git hook respects local configuration files
If none of the Git hook default parameters are overridden, do not
pass them in to the StyleGuide to not override the local
configuration.
2013-10-26 13:58:37 -05:00
Florian Rathgeber
fafa844dce Bugfix: get the parser if no vcs found in install_hook 2013-09-14 16:53:39 +01:00
Tobias Megies
d8f2bd92b8 revert checking for string and just pass a string to run() instead of a list 2013-10-10 09:16:28 +02:00
Tobias Megies
b98d036e06 bugfix: shift a line into loop 2013-10-10 09:00:42 +02:00
Tobias Megies
06256daf3a remove encoding/decoding of staged files 2013-10-10 09:00:06 +02:00
Tobias Megies
b8bd62dbc2 git hook: try to encode/decode with correct encoding (try to detect from file header) 2013-10-09 21:27:01 +02:00
Tobias Megies
74c6958e57 make git_hook check staged versions of files instead of local version
copies all staged versions of files to check in a temporary folder and runs
checks on this folder.
2013-10-08 12:35:58 +02:00
Laurent Bachelier
d9fe125957 Fix hook file permissions
On my system (Python 2.7), I would end up with "--wxr-x--T".
This solution should work everywhere.
2013-07-14 13:15:51 +02:00
Ian Cordasco
d3faf6afab Fix git hook on python 3
We were expecting strings not bytearrays and so we'll make sure we get
strings. And yes, unicode strings work just fine with this on python 2.
2013-07-04 11:29:12 -04:00
Rob Hudson
0f90a8aca5 Update hooks.py
Added --diff-filter to ignore deleted files.
2013-04-02 15:41:43 -07:00
Ian Cordasco
57417b435a Merged in develop (pull request #35)
Fix mercurial hook, issue #88
2013-04-01 09:50:13 -04:00
Ian Cordasco
490b46c7ab Yay I can't type any more 2013-03-24 16:50:18 -04:00
Ian Cordasco
f333b22ba6 Silly python 2.5 binary is for kids 2013-03-24 16:40:20 -04:00
Ian Cordasco
4efd19ce09 Fix #91 (bitbucket)
Non python files were being included in the git hook. Also, I realized that
with --install-hook on git projects, the file was not readable to the user.
Using binary helps clarify the use of chmod since I had erroneously used the
744 like the commandline does.
2013-03-24 15:59:09 -04:00
Florent Xicluna
53f907b1d2 Fix mercurial hook, issue #88 2013-02-26 18:11:20 +01:00
Ian Cordasco
9844142528 Update the VCS docs
Also, update the git_hook auto-installer text.
Fixes #87 on BitBucket
2013-02-26 11:39:17 -05:00
Ian Cordasco
ea1c29ca2e Fixes #86 on bitbucket
Create hgrc if it doesn't exist.
2013-02-25 22:50:57 -05:00
Florent Xicluna
80fe5da14c Fix space 2013-02-25 10:48:36 +01:00
Ian Cordasco
257eae684e Add docs 2013-02-22 23:18:15 -05:00
Florent Xicluna
7362d57c24 Restore the whole-file-skip feature 2013-02-20 21:14:13 +01:00
Florent Xicluna
e4afd25312 Small refactoring in the hooks module 2013-02-20 18:41:29 +01:00
Florent Xicluna
29b74f9b37 Wrong exit code for the VCS hooks 2013-02-13 21:26:28 +01:00
Florent Xicluna
701ec32e3f Fix the commit hooks, hopefully 2013-02-13 19:21:37 +01:00
Kevin Stanton
e236b7f6b3 Add support for the pep8 config file
Closes #55.
2013-01-09 11:31:41 -05:00