Package: pre-commit-git-checks
A series of basic Git checks meant for linting of your work.ContentsInstallationPython packagepre-commit hookUsagePython CLIHooksgit-signoffLicenseInstallationThis tool can be installed as a Python package or a pre-commit hook.Python packageInstall usingpipwith:pipinstallpre-commit-git-checkspre-commit hookpre-commitis a framework that is used for the
automated identification of issues in software.pre-commit-git-checkscan be run as a Git hook script before submitting
your code.To installpre-commitfollow the stepshere.You can see how to integrate a specific hook in the section below.UsagePython CLIYou can run this tool from the command line.To see the help dialog:$pgchecks--helpUsage:pgchecks[OPTIONS]COMMAND[ARGS]...Apre-commitcheckingtoolforGitOptions:--helpShowthismessageandexit.Commands:signoffChecksyourGitcommitmessagesforasignoffExample usage:$pgcheckssignoff[ERROR]Sign-offmessageexpectedtobe'Signed-off-by: Kostas Doe <kdoe@email.com>'.[INFO]Checkyourcurrentgitconfiguration(`gitconfig-l`)andrun`gitcommit--signoff`tosignoff.HooksIn your.pre-commit-config.yamlfile 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:Forgit-signoff:pre-commitinstall--hook-typecommit-msgNoteRunning thepre-commitinstall--hook-type<hook-type>command will
install all the hooks that include in theirstagesthe<hook-type>value (e.g.,commit-msg). Keep in mind that hooks that do not havestagesdefined are by default set to all stages, and therefore will
always also be installed to the given<hook-type>as well.
You can find more detailshere.To run individual hooks use:pre-commitrun--hook-stage<stage><hook_id>git-signoffWhatWith the commandgit commit--signoff/-sa committer adds aSigned-off-bytrailer 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.NoteThe purpose of this hook is to identify commit messages that have not been
explicitly signed off by the committer, and not to automatically add a Signed-off-by
line to the message.WhyAs mentioned in thegit commitdocumentation: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. (Seehttp://developercertificate.orgfor 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.HowThe pre-commit hook and script command checks:If auser.nameGit 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 theuser.emailconfiguration.If theuser.nameconfiguration resembles the format ‘Your Name’ and throws
a warning in case it does not.If theuser.emailconfiguration 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 upuser.nameanduser.emailconfigurations and throws an error in case it does not.Sign-off message is expected to be: ‘Signed-off-by: {user.name} <{user.email}>’WhenThe hook runs right after you save your commit message, as acommit-msghook (seehttps://git-scm.com/docs/githooks#_commit_msg). If the script exits
non-zero, Git aborts the commit process.For more information check out thepre-commitdocumentation,https://pre-commit.com/#pre-commit-for-commit-messages.LicenseMIT License