Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ repos:
entry: contrib/scripts/conventional-commits
language: script
stages: [commit-msg]
- id: signed-commit
name: Signed Commit Enforcer
entry: contrib/scripts/signed-commit
language: script
stages: [commit-msg]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
Expand Down
10 changes: 9 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@
language: script
description: Conventional Commits Enforcement at the `git commit` client-side level
always_run: true
stages: [commit-msg]
stages: [commit-msg]

- id: signed-commit
name: Signed Commit Enforcer
entry: contrib/scripts/signed-commit
language: script
description: Ensures all commits contain a Signed-off-by line
always_run: true
stages: [commit-msg]
17 changes: 17 additions & 0 deletions contrib/scripts/signed-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

if [[ -z "$1" ]] || [[ ! -f "$1" ]]; then
echo "ERROR: Commit message file not provided or does not exist."
exit 1
fi

# Check if signed-off-by line is present (automatically added using -s flag)
if ! grep -q 'Signed-off-by:' "$1"; then
echo "ERROR: Commit message must contain a Signed-off-by line."
echo ""
echo "To sign your commits, use the -s flag:"
echo " git commit -s -m \"your commit message\""
exit 1
fi

exit 0
Loading