From ad6977c2f85b96b972ee77876129850e6cc65bc5 Mon Sep 17 00:00:00 2001 From: Jakob Weisblat Date: Mon, 19 Jun 2017 13:20:24 +0200 Subject: [PATCH] edit detect_private_key to ignore directories instead of trying to open them as files --- pre_commit_hooks/detect_private_key.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pre_commit_hooks/detect_private_key.py b/pre_commit_hooks/detect_private_key.py index feb2208..097c01d 100644 --- a/pre_commit_hooks/detect_private_key.py +++ b/pre_commit_hooks/detect_private_key.py @@ -1,6 +1,7 @@ from __future__ import print_function import argparse +import os import sys BLACKLIST = [ @@ -19,6 +20,8 @@ def detect_private_key(argv=None): private_key_files = [] for filename in args.filenames: + if os.path.isdir(filename): + continue with open(filename, 'rb') as f: content = f.read() if any(line in content for line in BLACKLIST):