add tests, test sample files and minor refactor of exit codes in actual hook in order to facilitate testing
diff --git a/pre_commit_hooks/detect_aws_credentials.py b/pre_commit_hooks/detect_aws_credentials.py
index 10642af..e28724a 100644
--- a/pre_commit_hooks/detect_aws_credentials.py
+++ b/pre_commit_hooks/detect_aws_credentials.py
@@ -3,6 +3,7 @@
import argparse
import os
+
from six.moves import configparser
@@ -12,7 +13,7 @@
"""
aws_credentials_file_path = os.path.expanduser(credentials_file)
if not os.path.exists(aws_credentials_file_path):
- exit(2)
+ return None
parser = configparser.ConfigParser()
parser.read(aws_credentials_file_path)
@@ -37,13 +38,15 @@
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*', help='Filenames to run')
parser.add_argument(
- "--credentials-file",
+ "--credentials-file",
default='~/.aws/credentials',
help="location of aws credentials file from which to get the secret "
"keys we're looking for",
)
args = parser.parse_args(argv)
keys = get_your_keys(args.credentials_file)
+ if not keys:
+ return 2
retv = 0
for filename in args.filenames: