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
18 changes: 18 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

COMMIT_MESSAGE_FILE_PATH=$1
MESSAGE=$(cat "$COMMIT_MESSAGE_FILE_PATH")

if [[ $(head -1 "$COMMIT_MESSAGE_FILE_PATH") == '' ]]; then
exit 0
fi

POSTFIX=$(git branch | grep '\*' | sed 's/* //' | sed 's/^.*\///' | sed 's/^\([^-]*-[^-]*\).*/\1/')

COMMIT_SOURCE=$2

if [ "$COMMIT_SOURCE" != "merge" ]; then
if [[ "$MESSAGE" != *"[#$POSTFIX]"* ]]; then
printf "%s\n\n[#%s]" "$MESSAGE" "$POSTFIX" > "$COMMIT_MESSAGE_FILE_PATH"
fi
fi
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
init:
git config core.hooksPath .githooks
5 changes: 5 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Setup Git Hooks

```bash
$ make
```
5 changes: 5 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

make
cat SETUP.md >> README.md
rm SETUP.md setup.sh