Commit graph

89 commits

Author SHA1 Message Date
Anthony Sottile
1858edd9da Merge pull request #135 from Lucas-C/master
trailing-whitespace hook: restoring original file in case of failure - fixes #134
2016-08-31 07:35:34 -07:00
Lucas Cimon
cb23c48b0d Post-review fixes 2016-08-31 11:44:59 +02:00
Lucas Cimon
c3c870c398 trailing-whitespace hook: support for CRLFs 2016-08-30 10:34:06 +01:00
Anthony Sottile
8be6f4c77e Remove pylint 2016-08-22 14:38:49 -07:00
Lucas Cimon
eaad923dd4 trailing-whitespace hook: Switching from using fileinput to a tempfile and whitespace substitution in binary mode 2016-08-20 11:59:10 +01:00
Lucas Cimon
bc5e7f2d72 trailing-whitespace hook: restoring original file in case of failure - fixes #134 2016-08-19 18:26:33 +02:00
Anthony Sottile
a43122c5f4 Merge pull request #133 from pre-commit/customizable_encoding_pragma
Allow encoding pragma to be customizable
2016-08-12 19:19:28 +02:00
Anthony Sottile
693709e761 Allow encoding pragma to be customizable 2016-08-12 10:11:10 -07:00
Vinay Karanam
81bd74d9c3 coverage fix 2016-07-03 04:31:19 +05:30
Vinay Karanam
c58ae08fed requirements fixer output is similar to pip freeze 2016-07-03 04:10:20 +05:30
Oscar-Garcia
ea320d7463 Update debug_statement_hook.py
Adds celery rdb as debugger: http://docs.celeryproject.org/en/latest/tutorials/debugging.html
2016-06-20 09:41:22 +02:00
Anthony Sottile
6dfcb89af3 Merge pull request #122 from sanmai-NL/JSON_arbitrary_indentation_separator
Fix exception raising logic to match validation issues
2016-06-13 08:50:53 -07:00
Sander Maijers
abaf0d12de
Fix exc. raising logic to match validation issues 2016-06-13 11:34:55 +02:00
Anthony Sottile
cf3aabe9b1 Merge pull request #120 from sanmai-NL/JSON_arbitrary_indentation_separator
Refactor legacy `indent: int` -> `indent: str`
2016-06-12 10:25:59 -07:00
Sander Maijers
a5628863e8
Refactor legacy indent: int -> indent: str
The type of `indent` parameter is preferably `str`. See
http://simplejson.readthedocs.io/en/latest/index.html?highlight=dump#simplejson.dump
. This change allows to specify TABs as indentation delimiter to
`pretty_format_json`. Add input validator/converter for backward compat.
2016-06-12 19:19:07 +02:00
Anthony Sottile
4a01f64c8f Fix check-merge-conflict against binary files 2016-05-26 11:20:32 -07:00
Anthony Sottile
03bf17f2b0 Add a --remove option to fix-encoding-pragma 2016-04-27 11:18:14 -07:00
Anthony Sottile
17478a0a50 Style fixups 2016-04-14 08:25:52 -07:00
Anthony Sottile
ea867c2e68 Merge pull request #109 from mattclegg/no-sort-keys
Adding no-sort-keys to pretty_format_json
2016-04-14 08:11:26 -07:00
mattclegg
f775891717 Drop messy py26 support in favour of 100% coverage 2016-04-14 11:16:18 +01:00
mattclegg
700b18ed0e Use OrderedDict to preserve order 2016-04-14 10:23:42 +01:00
Anthony Sottile
fe9c404019 Forbid files with a UTF-8 BOM 2016-03-18 10:59:31 -07:00
Sébastien Larivière
f769c208bc Addding no-sort-keys to pretty_format_json, this allows to disable the sort on the keys 2016-03-12 17:04:33 -05:00
Anthony Sottile
d444ab821d Improve error message when credentials file is not provided 2016-02-08 17:18:56 -08:00
Anthony Sottile
d740faeded Typo in no cover comment 2016-02-03 11:12:51 -08:00
Anthony Sottile
8d80d51cad Fix coverage on check_symlinks for windows 2016-01-15 07:41:58 -08:00
Anthony Sottile
eff3eafcbb Merge pull request #98 from bchess/check_symlinks
New hook tests for broken symlinks
2016-01-15 07:38:46 -08:00
Anthony Sottile
d466a2e52c no cover some non-lfs lines 2016-01-14 18:57:03 -08:00
Benjamin Chess
896c0cfdc0 new hook tests for broken symlinks 2016-01-14 15:25:46 -08:00
Anthony Sottile
3f6f23d73f Teach check-large-files-added about git-lfs. Reslves #82. 2015-12-28 05:38:06 -08:00
Corey Christous
a23c58298c Reformatted --diff-filter git argument
This makes the command compatible with older versions of git.
2015-12-01 16:59:22 -05:00
phoxelua
58edfc8af6 Fixed regex matching 2015-11-19 00:39:29 -08:00
Anthony Sottile
aa2ba6f94f Add encoding pragma hook. Resolves pre-commit/pre-commit#15 2015-11-13 12:39:43 -08:00
Dean Wilson
a6665279e7 Show names of files containing aws credentials 2015-10-28 05:13:37 +00:00
Chris Kuehl
a1b0104f3d Sort requirements.txt case-insensitively 2015-08-17 12:43:13 -07:00
Anthony Sottile
8a8aaf5a60 Add a hook to verify python ast. 2015-08-04 13:48:30 -07:00
Chris Kuehl
ca2be345a1 detect_private_key: print *filenames*, not the key 2015-08-01 17:02:29 -07:00
Anthony Sottile
99574324eb Merge pull request #60 from arahayrabedian/master
AWS credential checking
2015-06-17 11:46:15 -07:00
Ara Hayrabedian
974ef4e93c disable import checking for six.moves 2015-06-13 14:18:08 +04:00
Ara Hayrabedian
02e8bdc9d8 add tests, test sample files and minor refactor of exit codes in actual hook in order to facilitate testing 2015-06-12 19:20:56 +04:00
Ara Hayrabedian
88725503c4 remove print statement 2015-06-12 17:02:06 +04:00
Ara Hayrabedian
3078aec57b use six for config parser, add to reqs
ditch checkign access_key (don't consider these a secret)
don't check line by line, check the whole file in bulk instead
2015-06-12 16:24:01 +04:00
Anthony Sottile
07c938e1b1 Allow arbitrary binary to pass the private key hook check. Resolves #64 2015-06-11 13:28:10 -07:00
Léo Cavaillé
55bf22dc4a Add new hook pretty-format-json
This new hook allows to standardize one's JSON files (sorted key/4
spaces indent).
By default it just fails if any file is not complying with the standard,
but you can also pass the arg `--autofix` and the hook will
pretty-format the file itself.

Good in use combined with the `check-json` hook.
2015-06-11 00:08:03 -04:00
Ara Hayrabedian
95bf20d52d add aws credential checking ONLY FOR YOUR OWN credentials if they're set in a configurable credentials file (AWS CLI tools' native format) 2015-06-01 23:16:51 +04:00
Alexander Dupuy
a6023ac0d7 Implement Markdown trailing space line break preservation
Markdown uses two or more trailing spaces on a line to indicate a forced
line break `<br/>` - these will be preserved for files with a markdown
extension (default = `.md` or `.markdown`).

Add `--markdown-linebreak-ext=X,Y` to add extensions (`*` matches any),
and `--no-markdown-linebreak-ext` to disable this feature.

If you want to set specific extension `foo` only (and not md/markdown),
use `--no-markdown-linebreak-ext --markdown-linebreak-ext=foo`

Tries to prevent --markdown-linebreak-ext from eating filenames as if they were
extensions by rejecting any with '.' or '/' (or even Windows-style '\' or ':')

Update README.md to include information on these arguments as well as
arguments added to other hooks

Add extensive tests using pytest.mark.parametrize

test that `txt` file is not considered as 'txt' extension
test that `.txt` file is not considered as 'txt' extension

The latter is the (correct) behavior of os.path.splitext(), and an example
of why it is better to use the libraries than to mangle strings yourself.
2015-05-11 08:52:32 +02:00
Alexander Dupuy
5c752935fd Refactor check-merge-conflicts tests
Do a straight test of detecting a real merge conflict as generated by git.
Test artificial conflict detection while pending merge without a real conflict.
Test artificial non-conflict non-detection in a resolved merge conflict.
Rename test_does_not_care... function to reflect what we want to care about.
Rename is_in_merge_conflict to is_in_merge since that is what it checks.
2015-05-09 04:29:38 +02:00
Alexander Dupuy
eefc46f901 Don't report markup titles as merge conflicts
Several markup formats, such as Markdown or Re(Structured)Text
can format titles as text with '=' characters as double underlining,
like this:
```
My Page Title
=============

Lorem ipsum...
```

Rather that considering any line starting with seven '=' as a conflict marker,
require a space (or line-ending newline) after the equals.
This could still create a false positive for a seven character title,
like "Problem", but the markup formats generally allow extra '=' characters,
so by formatting the text like this:
```
Problem
========

Not...
```
these pre-commit warnings can be avoided.

Also updates the tests to add newlines for more realistic conflict files
(while a file might not end with a newline, conflict markers will).
Prevent false negative on test_does_not_care_when_not_in_a_conflict()
by making sure that README.md contains a line identical to a conflict string
(exactly seven '=' followed by a newline).
2015-05-09 04:20:38 +02:00
Mike Cooper
edee3f64b9 Add q as a debug statement
q is a debugging tool: https://pypi.python.org/pypi/q
2015-04-10 10:55:33 -07:00
Anthony Sottile
635fa7dd9d Only check merge conflicts on conflict commits 2015-03-20 16:21:02 -07:00