Show last authors
1 = DCO commit-msg Hook =
2
3 The below script can be used as a very basic commit-msg hook to verify that all commits are signed off by the DCO. To install this copy the below file to {{code language=bash}}.git/hooks/commit-msg{{/code}} in your local clone of the git repository. Please ensure to remove the sample {{code language=bash}}.git/hooks/commit-msg.sample{{/code}} and ensure the new script is executable, {{code language=bash}}chmod +x .git/hooks/commit-msg{{/code}}. It will run every commit and fail if the DCO is not present in a commit message. You could customize this hook further to check for your specific name and e-mail sign off to ensure you sign off any commits merged from other developers, see the example below.
4
5 {{code}}
6 #!/usr/bin/env bash
7 #
8 # Basic hook to check for DCO
9 #
10
11 commit_regex='^Signed-off-by: '
12 error_msg="Your commit message is not signed off with the DCO"
13
14 if ! grep -qE "$commit_regex" "$1"; then
15 echo "$error_msg" >&2
16 exit 1
17 fi
18 {{/code}}
19
20 Below is a variant to address the need to sign off with a specific e-mail domain.
21
22 {{code}}
23 #!/usr/bin/env bash
24 #
25 # Basic hook to check for DCO
26 #
27
28 commit_regex='^Signed-off-by: .* \<.*@codeaurora.org\>'
29 error_msg="Your commit message is not signed off with the DCO and correct e-mail domain"
30
31 if ! grep -qE "$commit_regex" "$1"; then
32 echo "$error_msg" >&2
33 exit 1
34 fi
35 {{/code}}

My Recent Modifications

Need help?

If you need help with XWiki you can contact: