Commit graph

137 commits

Author SHA1 Message Date
Morgan Courbet
d16d04a4d7
Fix the 5 remaining tests for Python 3.4 & 3.5
Fixes nagromc/pre-commit-hooks#1
2017-07-09 11:16:20 +02:00
Morgan Courbet
ba63d1b9db
Refactor _process_no_fix 2017-07-08 10:30:09 +02:00
Morgan Courbet
3dbeeeefe5
Improve test coverage 2017-07-04 22:55:49 +02:00
Morgan Courbet
609d01178c
Improve logging for force line ending 2017-07-04 21:26:02 +02:00
Morgan Courbet
a1e1421a99
Refactor mixed_line_ending 2017-07-04 21:23:03 +02:00
Morgan Courbet
614893f36d
Fix _process_fix_auto to return the right value 2017-07-04 21:18:29 +02:00
Morgan Courbet
c6c4c4a2fa
Refactor mixed_line_ending 2017-07-04 21:07:00 +02:00
Morgan Courbet
a1ffbfaa59
Add mixed line detection 2017-07-04 20:50:49 +02:00
Morgan Courbet
4270b56e50
Refactor MixedLineDetection 2017-07-04 20:49:11 +02:00
Morgan Courbet
b1294b8614
Add unit test for mixed_line_ending 2017-07-03 20:04:03 +02:00
Morgan Courbet
f477582ae6
Add logs to mixed_line_ending.py 2017-07-03 18:52:18 +02:00
Morgan Courbet
22b228210e
Reuse variable definition 2017-06-29 21:46:25 +02:00
Morgan Courbet
2b28f4f051
Rename variable names 2017-06-29 21:42:19 +02:00
Morgan Courbet
0a8b929f07
Change files according to --fix option 2017-06-29 21:16:17 +02:00
Morgan Courbet
aaf134c2bc
Add line ending conversion 2017-06-28 22:15:31 +02:00
Morgan Courbet
466f9e1732
Add line ending detection 2017-06-27 21:56:18 +02:00
Morgan Courbet
ad0062a3bb
Add filenames option 2017-06-26 21:42:27 +02:00
Morgan Courbet
b2b0d5929a
Use enum instead of raw argparse result 2017-06-26 21:31:44 +02:00
Morgan Courbet
93194b9c6a
Change --fix option from mixed_line_ending
To make it easier to use in the program (single string instead of a list
of strings)
2017-06-18 12:31:22 +02:00
Morgan Courbet
51866649a6
Split argument parsing from main mixed line ending function 2017-06-18 12:25:42 +02:00
Morgan Courbet
afaa97cd11
Add enum to mixed_line_ending --fix option 2017-06-17 19:45:39 +02:00
Morgan Courbet
16b7c7af5d
Use Enum to list line ending types in mixed_line_ending 2017-06-15 20:36:34 +02:00
Morgan Courbet
3d4fb41d8a
Add mixed-line-ending processor 2017-06-13 21:56:00 +02:00
Anthony Sottile
dc50b7f09c Attempt to fix the json hook under test 2017-03-20 11:25:45 -07:00
Evan Felix
a8592669d9 Add a no commit to specific branch hook. (#185)
* add no commit code and config

* add the code

* remove version tweak

* fix logic, remove newline

* add Tests and cleanup testing issues

* remove extraneous modules

* cleanup some pep8 and flake issues

* reorder imports

* more fixes for syntax checking

* code cleanup based off asottile comments

* Use Contractions Properly, alphabatize new hook.

* Adding support for branches with a slash in them.
2017-03-20 10:36:51 -07:00
Anthony Sottile
b95dcad616 Fixups 2017-03-20 08:24:58 -07:00
John Hu
543c5c7e1a Add an option to disable ensure_ascii 2017-03-20 20:19:01 +08:00
Oliver Zhou
c380d0b3e3 Handling default django test filename of "tests.py" 2017-03-15 00:40:53 -07:00
Anthony Sottile
9cee71b5df Add pyupgrade 2017-03-12 18:01:29 -07:00
Mike Fiedler
312e721ce9
Add flag to detect-aws-credentials to allow missing keys
In the event that there exists no configuration for AWS credentials and
they are not exported in to the current environment, a flag may be
passed to allow exiting the hook successfully.

Resolves #174

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
2017-02-10 12:54:03 -05:00
Anthony Sottile
81147337c5 Only return nonzero when rewriting whitespace 2017-02-07 09:45:31 -08:00
Anthony Sottile
5da199bb8d Formatting fixups 2017-01-03 13:13:44 -08:00
Anthony Sottile
47996656b4 Merge pull request #162 from Dunedan/improve-aws-credential-searching
Improve searching for configured AWS credentials
2017-01-03 16:11:30 -05:00
Anthony Sottile
a7971b7d26 appveyor installed git-lfs, fix coverage 2017-01-03 12:56:22 -08:00
Daniel Roschka
3939aee4a3 Address issues mentioned in review 2017-01-03 19:05:49 +01:00
Daniel Roschka
0fd09bf67a Add AWS_CONFIG_FILE to the environment variables
Turns out there is an additional environment variable AWS_CONFIG_FILE,
which gets evaluated for finding configuration files as well. This
commit adds support for it.
2016-12-30 10:39:38 +01:00
Daniel Roschka
b0d4cdb1ee Improve searching for configured AWS credentials
The previous approach for finding AWS credentials was pretty naive and
only covered contents of a single file (~/.aws/credentials by
default).

The AWS CLI documentation states various other ways to configure
credentials which weren't covered:
https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#credentials
Even that aren't all ways, a look into the code shows:
https://github.com/boto/botocore/blob/develop/botocore/credentials.py

This commit changes the behavior so the hook will behave in a way
that if the AWS CLI is able to obtain credentials from local files,
the hook will find them as well.

The changes in detail are:
- detect AWS session tokens and handle them like secret keys.
- always search credentials in the default AWS CLI file locations
  ( ~/.aws/config, ~/.aws/credentials, /etc/boto.cfg and ~/.boto)
- detect AWS credentials configured via environment variables in
  AWS_SECRET_ACCESS_KEY, AWS_SECURITY_TOKEN and AWS_SESSION_TOKEN
- check additional configuration files configured via environment
  variables (AWS_CREDENTIAL_FILE, AWS_SHARED_CREDENTIALS_FILE and
  BOTO_CONFIG)
- print out the first four characters of each secret found in files to
  be checked in, to make it easier to figure out, what the secrets
  were, which were going to be checked in
- improve error handling for parsing ini-files
- improve tests

There is a major functional change introduced by this commit:
Locations the AWS CLI gets credentials from are always searched and
there is no way to disable them. --credentials-file is still there to
specify one or more additional files to search credentials in. It's
the purpose of this hook to find and check files for found
credentials, so it should work in any case. As this commit also
improves error handling for not-existing or malformed configuration
files, it should be no big deal.

Receiving credentials via the EC2 and ECS meta data services is not
covered intentionally, to not further increase the amount of changes
in this commit and as it's probably an edge case anyway to have this
hook running in such an environment.
2016-12-30 08:41:24 +01:00
Chris Kuehl
cdb3e2e4bf Add trailing comma 2016-12-26 14:51:26 -08:00
Daniel Roschka
c549cb25a1 Detect Ed25519 keys as well
Ed255519 keys generated by OpenSSH contain "BEGIN OPENSSH PRIVATE KEY"
as identifier. This commit adds coverage for such keys as well.
2016-12-26 19:09:53 +01:00
Chris Kuehl
4b928ab06b Add forbid-new-submodules to hooks.yaml 2016-11-30 10:25:51 -08:00
Anthony Sottile
70e405ede2 Add a new hook to forbid new submodules 2016-11-30 09:56:42 -08:00
Chris Kuehl
6b9265c96a Fix JSON decode error message 2016-11-12 11:54:14 -08:00
Lucas Cimon
54e83f7ceb Displaying the filename when the check-json hook fails with a UnicodeDecodeError - fix #148 2016-11-12 09:15:10 +01:00
dmlb2000
84b1fb6827 let pre-commit fix some stuff 2016-11-03 15:54:48 -07:00
dmlb2000
c7ab197645 don't need to blow away the space here 2016-11-03 15:49:04 -07:00
dmlb2000
d06a515ce1 this is much cleaner and might actually get all the coverage with out a bunch of work 2016-11-03 15:47:21 -07:00
dmlb2000
845a3d5bdf adds top keys list of keys in hashes to put at the top of a hash
This adds custom sorting to preferencially add a list of top keys
at the start of any json hash in the json document
2016-11-03 09:41:23 -07:00
Brett Delle Grazie
a234b23667 Use safe_load as per PyYAML documentation
resolves #104
2016-10-23 17:50:42 +01:00
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