Add Push Rule for DCO Signoff
What does this MR do and why?
Adds a Push rule to validate commits for a DCO Signoff (Signed-off-by:
trailer)
Functionality and implementation is similar to the 'reject unsigned commits' push rule, except for here we just check for the trailer in the commit message.
Resolves #368894 (closed)
Builds on the Migration introduced in !97938 (merged)
Screenshots or screen recordings
Admin push rule
Project push rule
Command line:
No Signoff:
╰─$ git --no-pager log -n1
commit 72262fef62743235069a2bc48801dd1ea51e858a (HEAD -> testing)
Author: Raimund Hook <raimund@example.com>
Date: Fri Sep 16 14:07:28 2022 +0100
Add regular commit
╰─$ git push -u origin testing -v
Pushing to ssh://gdk.test:2222/flightjs/Flight.git
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 10 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 294 bytes | 294.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: GitLab: Commit must contain DCO Sign-off
To ssh://gdk.test:2222/flightjs/Flight.git
! [remote rejected] testing -> testing (pre-receive hook declined)
error: failed to push some refs to 'ssh://gdk.test:2222/flightjs/Flight.git'
With Signoff:
╰─$ git commit --amend -s 1 ↵
[testing 2d0f53e] Add regular commit
Date: Fri Sep 16 14:07:28 2022 +0100
1 file changed, 1 insertion(+)
╰─$ git --no-pager log -n1
commit 2d0f53ee7ceca49005463e309da557c05424ec27 (HEAD -> testing)
Author: Raimund Hook <raimund@example.com>
Date: Fri Sep 16 14:07:28 2022 +0100
Add regular commit
Signed-off-by: Raimund Hook <raimund@example.com>
╰─$ git push -u origin testing
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 10 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 316 bytes | 316.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for testing, visit:
remote: http://gdk.test:3000/flightjs/Flight/-/merge_requests/new?merge_request%5Bsource_branch%5D=testing
remote:
To ssh://gdk.test:2222/flightjs/Flight.git
* [new branch] testing -> testing
branch 'testing' set up to track 'origin/testing'.
How to set up and validate locally
- Enable rule on a project
- Commit a change that does not contain
Signed-off-by: User Name <user@example.com>
as a commit trailer - Push the commit
- Observe that the commit is rejected
- Sign the commit (
git commit -s --amend
) - Push the commit
- Observe that the commit is successful
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Raimund Hook