pre-commit hook to add "signed-off-by" line to commit messages
Project description
sign-off
Hook for pre-commit to add a signature line to commit messages.
The hook is running in the prepare-commit-msg
-stage and intended to add
Signed-off-by:
-lines often used in the context of
DOC, but it
should be flexible enough for other use-cases as well.
Using with pre-commit
Add this to your .pre-commit-config.yaml
:
- repo: https://github.com/dynobo/sign-off
rev: v0.1.0
hooks:
- id: sign-off
The default behavior is to append a signature line (if it does not yet contain
Signed-off-by:
as substring) which will result in a commit message like:
Changed something important
Signed-off-by: dynobo <dynobo@mailbox.org>
Optional arguments
You can add two optional arguments in the .pre-commit-config.yaml
, e.g. here
are the defaults:
- repo: https://github.com/dynobo/sign-off
rev: v0.1.0
hooks:
- id: sign-off
- args:
- '--template=\n\nSigned-off-by: <GIT_AUTHOR_IDENT>'
- '--skip-containing=Signed-off-by:'
The argument --template
defines the text or template that is going to be
appended right after the commit message. Be sure to add white space in the
template, if needed.
The argument --skip-containing
is a stopping criteria: If this string is
contained somewhere in the commit message, the signature text will not be
appended. This avoids appending the same signature twice, when doing
git --amend
or such.
If you want to always add the the signature, set the argument, but leave it's
value empty empty: --skip-containing=
Both arguments support template tags in the form <VariableName>
, where
VariableName
is one of the variables displayed when running git var -l
. The
template tag will be replaced by the variables value in the corresponding
string.
The values of the two git variables GIT_AUTHOR_IDENT
and GIT_COMMITER_IDENT
contain a timestamp at the end, which will get stripped when used as template
tag.
You can add additional "git vars", e.g. if you add the following section to your
.gitconfig
...
[my-signature]
hash = sha:123456789
company_mail = dynobo@dynobo.corp
... then you can use those variables in the hook:
- repo: https://github.com/dynobo/sign-off
rev: v0.1.0
hooks:
- id: sign-off
- args:
- '--template=\n\nBy: <my-signature.company_mail> (<my-signature.company_mail>)'
- '--skip-containing=\nBy: '
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.