Skip to main content

pre-commit-git-checks

A series of basic Git checks meant for linting of your work.

Installation

This tool can be installed as a Python package or a pre-commit hook.

Python package

Install using pip with:

pip install pre-commit-git-checks

pre-commit hook

pre-commit is a framework that is used for the automated identification of issues in software.

pre-commit-git-checks can be run as a Git hook script before submitting your code.

To install pre-commit follow the steps here.

You can see how to integrate a specific hook in the section below.

Usage

Python CLI

You can run this tool from the command line.

To see the help dialog:

$ pgchecks --help

Usage: pgchecks [OPTIONS] COMMAND [ARGS]...

  A pre-commit checking tool for Git

Options:
  --help  Show this message and exit.

Commands:
  signoff  Checks your Git commit messages for a signoff

Example usage:

$ pgchecks signoff

[ERROR] Sign-off message expected to be 'Signed-off-by: Kostas Doe <kdoe@email.com>'.
[INFO] Check your current git configuration (`git config -l`) and run `git commit --signoff` to signoff.

Hooks

In your .pre-commit-config.yaml file add:

repos:
  - repo: https://github.com/KAUTH/pre-commit-git-checks
    rev: master
    hooks:
      - id: git-signoff
        stages: [commit-msg]

To install the hook(s) run:

  • For git-signoff:

pre-commit install --hook-type commit-msg

To run individual hooks use:

pre-commit run --hook-stage <stage> <hook_id>

git-signoff

What

With the command git commit --signoff/-s a committer adds a Signed-off-by trailer at the end of the commit log message.

This hook ensures that the committed message has been signed off with the information of the Git user.

The corresponding CLI command ensures that the commit message that is currently checked out has been signed off with the information of the Git user.

Why

As mentioned in the git commit documentation:

The meaning of a signoff depends on the project to which you’re committing. For example, it may certify that the committer has the rights to submit the work under the project’s license or agrees to some contributor representation, such as a Developer Certificate of Origin. (See http://developercertificate.org for the one used by the Linux kernel and Git projects.) Consult the documentation or leadership of the project to which you’re contributing to understand how the signoffs are used in that project.

How

The pre-commit hook and script command checks:

  • If a user.name Git configuration is set at a local level first or a global level and throws an error in the case it is not set in any scope. The same happens for the user.email configuration.

  • If the user.name configuration resembles the format ‘Your Name’ and throws a warning in case it does not.

  • If the user.email configuration resembles the format of an email and throws a warning in case it does not.

  • If the Git commit message is singed off with the currently set up user.name and user.email configurations and throws an error in case it does not.

Sign-off message is expected to be: ‘Signed-off-by: {user.name} <{user.email}>’

When

The hook runs right after you save your commit message, as a commit-msg hook (see https://git-scm.com/docs/githooks#_commit_msg). If the script exits non-zero, Git aborts the commit process.

For more information check out the pre-commit documentation, https://pre-commit.com/#pre-commit-for-commit-messages.

License

MIT License

Metadata

Release files for pre-commit-git-checks 0.0.1

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

Source distribution (sdist)

Source distribution for pre-commit-git-checks 0.0.1
File Size Uploaded
pre_commit_git_checks-0.0.1.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pre-commit-git-checks 0.0.1
File Interpreter ABI Platform
pre_commit_git_checks-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / pre_commit_git_checks-0.0.1.tar.gz

Download URL pre_commit_git_checks-0.0.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5dc4837bb6c9eec01a96154fce75e10c1c1e2e2f95cbe3506bc3bcbe38b54cf8
BLAKE2b-256 checksum
How to use checksums
2147e5ebff7ff79f076155ed5bd2bdcc37b591e7c5e9507d79a7e62fb3a6674f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / pre_commit_git_checks-0.0.1-py3-none-any.whl

Download URL pre_commit_git_checks-0.0.1-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e927ceb64a324267b92569ec7fb60ebef4e8a763ba601b726f67efd0edeaa0e
BLAKE2b-256 checksum
How to use checksums
098891a4fa95ddc465d1bf16e64c36277690ddc64cf5141d6b2a6b60715fd433
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

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