Skip to content

Commit

Permalink
Add a pre-commit hook to check for signed-off commits (#1168)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Schlicht <jan@d2iq.com>
  • Loading branch information
Jan Schlicht committed Feb 21, 2020
1 parent bbb21cd commit 47853d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Git hooks for KUDO. Install with
# pre-commit install -t pre-commit -t commit-msg
repos:
- repo: git://github.com/golangci/golangci-lint
rev: v1.22.0
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
description: Check that source code is linted
entry: make lint
language: system
stages: [commit]
- repo: local
hooks:
- id: signed-off-commits
name: signed-off-commits
description: Check that commit messages include a 'Signed-off-by' line
entry: ./hack/check-commit-signed-off.sh
language: script
stages: [commit-msg]
14 changes: 14 additions & 0 deletions hack/check-commit-signed-off.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

file="$1"

signedoff_regex='^Signed-off-by: '

if [ "$(grep -c "$signedoff_regex" "$file")" != "1" ]; then
printf >&2 "Signed-off-by line is missing.\n"
exit 1
fi

0 comments on commit 47853d3

Please sign in to comment.