Skip to content

Commit 05006f3

Browse files
committed
add git init hooks to makefile
Signed-off-by: Sam Heilbron <[email protected]> rename hook Signed-off-by: Sam Heilbron <[email protected]> executable Signed-off-by: Sam Heilbron <[email protected]>
1 parent af8bbaa commit 05006f3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.githooks/prepare-commit-msg.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
# This script automatically adds a Signed-off-by trailer to each commit message, so that your commits
4+
# will adhere to the DCO (Developer Certificate of Origin) requirements.
5+
# To use, run `make init-git-hooks` or copy this file to .git/hooks/prepare-commit-msg in your copy of the repo.
6+
7+
NAME=$(git config user.name)
8+
EMAIL=$(git config user.email)
9+
10+
if [ -z "$NAME" ]; then
11+
echo "empty git config user.name"
12+
exit 1
13+
fi
14+
15+
if [ -z "$EMAIL" ]; then
16+
echo "empty git config user.email"
17+
exit 1
18+
fi
19+
20+
git interpret-trailers --if-exists doNothing --trailer \
21+
"Signed-off-by: $NAME <$EMAIL>" \
22+
--in-place "$1"

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ all: build
7070
help: ## Display this help.
7171
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
7272

73+
##@ Git
74+
75+
.PHONY: init-git-hooks
76+
init-git-hooks: ## Use the tracked version of Git hooks from this repo
77+
git config core.hooksPath .githooks
78+
7379
##@ Development
7480

7581
.PHONY: manifests

0 commit comments

Comments
 (0)