Skip to main content

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

detect-direct-checkins is available on PyPI for Python 3.5+ and can be installed with pip:

python3 -m pip install detect-direct-checkins

If you use Arch Linux or one of its derivatives, you can also install detect-direct-checkins from the AUR:

yay -S python-detect-direct-checkins

You also find self-contained executables for 64-bit Linux distributions and macOS High Sierra and newer on the releases page. They are created with PyInstaller and only require glibc >= 2.17 on Linux (should be fine on any recent Linux system).

After the installation, 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.2
  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.

Metadata

Release files for detect-direct-checkins 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for detect-direct-checkins 0.1.2
File Size Uploaded
detect-direct-checkins-0.1.2.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for detect-direct-checkins 0.1.2
File Interpreter ABI Platform
detect_direct_checkins-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / detect-direct-checkins-0.1.2.tar.gz

Download URL detect-direct-checkins-0.1.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
13714b148f8d6be958cb99c737ab71efb9652f006178b5314500e53c504c6831
BLAKE2b-256 checksum
How to use checksums
80e68a8d71b6838060c680ae09aab0126401b2c14478904e38f8b6ae8d146702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release files / detect_direct_checkins-0.1.2-py3-none-any.whl

Download URL detect_direct_checkins-0.1.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10163ae168adcbd8c2b519671c3f87bb03495e75c9f6e2c8e1d280aa1cb0f5a7
BLAKE2b-256 checksum
How to use checksums
4e8d332be3275f104274f53a6f1c335f9ae314c0ef2fad96e6165599c5318a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page