nocommit pre-hook

This commit is contained in:
Manu Raghavan 2020-06-09 20:32:40 +00:00
parent f0bf512dbb
commit d3cb871783
5 changed files with 33 additions and 1 deletions

View file

@ -161,6 +161,12 @@
entry: name-tests-test
language: python
files: (^|/)tests/.+\.py$
- id: no-commit-keywords
name: "Don't commit when nocommit keyword is present"
entry: no-commit-keywords
language: script
always_run: true
types: [text]
- id: no-commit-to-branch
name: "Don't commit to branch"
entry: no-commit-to-branch

View file

@ -1,3 +1,9 @@
3.2.0 - 2020-06-10
==================
### Features
- `no-commit-keywords`: block commits when 'nocommit' or other keywords are present
3.1.0 - 2020-05-20
==================

View file

@ -123,6 +123,9 @@ Replaces or checks mixed line ending.
Assert that files in tests/ end in `_test.py`.
- Use `args: ['--django']` to match `test*.py` instead.
#### `no-commit-keywords`
Protect branches from checkins when 'nocommit' keyword is present. Used to remind the author to prevent work-in-progress state from being committed.
#### `no-commit-to-branch`
Protect specific branches from direct checkins.
- Use `args: [--branch, staging, --branch, master]` to set the branch.

View file

@ -0,0 +1,16 @@
#!/bin/bash
set -e
NOCOMMIT_PRESENT=$(git grep --ignore-case nocommit)
if [ -n $NOCOMMIT_PRESENT ]
then
echo "#nocommit tagged - commit prevented"
echo $NOCOMMIT_PRESENT
exit 1
else
exit 0
fi

View file

@ -1,6 +1,6 @@
[metadata]
name = pre_commit_hooks
version = 3.1.0
version = 3.2.0
description = Some out-of-the-box hooks for pre-commit.
long_description = file: README.md
long_description_content_type = text/markdown
@ -52,6 +52,7 @@ console_scripts =
forbid-new-submodules = pre_commit_hooks.forbid_new_submodules:main
mixed-line-ending = pre_commit_hooks.mixed_line_ending:main
name-tests-test = pre_commit_hooks.tests_should_end_in_test:main
no-commit-keywords = pre_commit_hooks.no_commit_keywords:main
no-commit-to-branch = pre_commit_hooks.no_commit_to_branch:main
pre-commit-hooks-removed = pre_commit_hooks.removed:main
pretty-format-json = pre_commit_hooks.pretty_format_json:main