A utility which detects direct checkins on specific branches.
Project description
detect-direct-checkins
Overview
The detect-direct-checkins
utility can be used to detect non-merge commits on given branches in a Git repository. It
can be run as a pre-commit framework hook.
Example Usage
Command line tool
Install the command line program with
python3 -m pip install "git+https://github.com/IngoMeyer441/detect-direct-checkins@master"
Switch your working directory to a Git repository you would like to check and run
detect-direct-checkins --branch release --allow-root
to check a branch release
for non-merge commits (but ignore initial root commits without parents).
Usage as a pre-commit hook
Add
- repo: https://github.com/IngoMeyer441/detect-direct-checkins
rev: 0.1.0
hooks:
- id: detect-direct-checkins
- args: ['--branch=release', '--allow-root']
to your .pre-commit-config.yaml
to detect direct checkins to a branch release
. The --allow-root
switch ignores
root commits (initial commits without parents).
The --branch
argument can be given multiple times to check more than one branch.
This check is a post-commit
check, so make sure to install the pre-commit framework as a post-commit
hook:
pre-commit install --hook-type post-commit
I recommend to set default_stages: ['commit']
in your .pre-commit-config.yaml
. Otherwise, most checks will run
twice (in the pre-commit
and post-commit
stage).
Important note: Since this is a post-commit
hook, this check will not avoid the creation of disallowed
commits. It only tells you that a disallowed commit has been created. However, you can run
pre-commit run --hook-type post-commit
as part of your CI pipeline to enforce this check. Direct-checkins to protected branches will cause this check to fail in a CI job.
Options
These options are supported:
--branch
: Branch which must only contain merge commits, can be given multiple times.--ignore
: Commit hashes which will be ignored, can be given multiple times--allow-root
: Allow root commits (commits without parents).
Contributing
Please open an issue on GitHub if you experience bugs or miss features. Please consider to send a pull request if you can spend time on fixing the issue yourself. This project uses pre-commit itself to ensure code quality and a consistent code style. Run
make git-hooks-install
to install all linters as Git hooks in your local clone of detect-direct-checkins
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for detect-direct-checkins-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e6feaf7da2a6f03040bbe27d7dfeb883b78b43e972120c62fec2a9283ebcdf0 |
|
MD5 | c9f30d3feb71675a649f22103d2cbec9 |
|
BLAKE2b-256 | b8a40138b14bde3d87a46cc5511ac7485e7311dd6807c7e699ea426c3b5053a9 |
Hashes for detect_direct_checkins-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dd949ec8af54674ea27fb4d55381f34da837e22adf07ffc08891692037048b6 |
|
MD5 | 6040eb239bb3aa246cb8327e0c6fff72 |
|
BLAKE2b-256 | 50163464b80f41ab4bb8083048fbf0bdc79506b4825ff33c1583181109597fae |