utils for implementing git pre-commit hook
Project description
git-pre-commit-hook-utils is utils for implemeting Git pre-commit hooks
Installation
You can install, upgrade, uninstall git-pre-commit-hook-utils with these commands:
$ pip install git-pre-commit-hook-utils $ pip install --upgrade git-pre-commit-hook-utils $ pip uninstall git-pre-commit-hook-utils
Features:
Work fine with initial commit
Work fine with all filenames
Work with index contents instead of working copy
Examples
Hook that reject commits with “big (>10Mib)” files:
import sys import git_pre_commit_hook_utils for file_for_commit in git_pre_commit_hook_utils.files_staged_for_commit(): if file_for_commit.size > 10 * 1024 * 1024: sys.exit(1) sys.exit(0)
Hook that reject invalid json files:
import sys import json import git_pre_commit_hook_utils for file_for_commit in git_pre_commit_hook_utils.files_staged_for_commit(): if file_for_commit.path.endswith('.json') try: json.loads(file_for_commit.contents) except Exception: sys.exit(1) else: sys.exit(0)
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for git-pre-commit-hook-utils-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47168cdf33165f186d5f8fd2f98719ade9ac9f97c73790916af6f2fabbff2fa9 |
|
MD5 | 6bb70705fcd09c92008b23f6dc28c378 |
|
BLAKE2b-256 | 8f99b9bef3ac7583bfe473eb4c2469cb8dbbb3df6ac7a18e9011ef9a6b0f84b7 |