From 3b46e97d47099961173eff962d7e0a9673e36cf1 Mon Sep 17 00:00:00 2001 From: Ilkka Laukkanen Date: Mon, 7 Dec 2015 15:41:55 +0200 Subject: [PATCH] Explicitly make global variables global Using Homebrew Python 2.7.10 on OS X, unless these variables are marked as global in `main` they become implicitly local since they are assigned. This prevents the hook from working because the implicitly local variables shadow their implicitly global counterparts in the rest of the code, and the global variables are never assigned. --- safe-commit-hook.py | 1 + 1 file changed, 1 insertion(+) diff --git a/safe-commit-hook.py b/safe-commit-hook.py index 4a030ed..4ef8849 100755 --- a/safe-commit-hook.py +++ b/safe-commit-hook.py @@ -103,6 +103,7 @@ def match_patterns(patterns, files, whitelist=None): exit(1) def main(): + global DEFAULT_PATTERNS, REPO_ROOT, WHITELIST DEFAULT_PATTERNS = os.path.expanduser('~/.safe-commit-hook/git-deny-patterns.json') REPO_ROOT = get_repo_root() WHITELIST = os.path.join(REPO_ROOT, '.git-safe-commit-ignore')