Skip to content

Commit 47853d3

Browse files
author
Jan Schlicht
authoredFeb 21, 2020
Add a pre-commit hook to check for signed-off commits (#1168)
Signed-off-by: Jan Schlicht <[email protected]>
1 parent bbb21cd commit 47853d3

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed
 

‎.pre-commit-config.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
# Git hooks for KUDO. Install with
2+
# pre-commit install -t pre-commit -t commit-msg
13
repos:
2-
- repo: git://github.com/golangci/golangci-lint
3-
rev: v1.22.0
4+
- repo: local
45
hooks:
56
- id: golangci-lint
7+
name: golangci-lint
8+
description: Check that source code is linted
9+
entry: make lint
10+
language: system
11+
stages: [commit]
12+
- repo: local
13+
hooks:
14+
- id: signed-off-commits
15+
name: signed-off-commits
16+
description: Check that commit messages include a 'Signed-off-by' line
17+
entry: ./hack/check-commit-signed-off.sh
18+
language: script
19+
stages: [commit-msg]

‎hack/check-commit-signed-off.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
file="$1"
8+
9+
signedoff_regex='^Signed-off-by: '
10+
11+
if [ "$(grep -c "$signedoff_regex" "$file")" != "1" ]; then
12+
printf >&2 "Signed-off-by line is missing.\n"
13+
exit 1
14+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.