Skip to content

Instantly share code, notes, and snippets.

@matrixcloud
Created January 27, 2021 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matrixcloud/f19fa810f2b709bf369c3dbeac3e242c to your computer and use it in GitHub Desktop.
Save matrixcloud/f19fa810f2b709bf369c3dbeac3e242c to your computer and use it in GitHub Desktop.
Gerrit commit message check for all projects
%filter to require all projects to have correct commit message
submit_filter(In, Out) :-
%unpack the submit rule into a list of code reviews
In =.. [submit | Ls],
%add commit message validator
require_commit_message_check(Ls, R),
%pack the list back up and return it
Out =.. [submit | R].
require_commit_message_check(S1, S2) :-
gerrit:commit_message_matches('^US|CR#[A-Z]+-\\d+:\\s[\\w\\W]+'),
!,
S2 = [label('Commit-Message', ok(user(1000))) | S1].
require_commit_message_check(S1, S2) :-
!,
S2 = [label('Commit-Message', reject(user(1000))) | S1].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment