Skip to content

Commit

Permalink
Explicitly make global variables global
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ilkka committed Dec 7, 2015
1 parent 85324c1 commit 3b46e97
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions safe-commit-hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 3b46e97

Please sign in to comment.