Last active
October 1, 2020 14:18
-
-
Save Donkfather/f9354d9a21d48eb26a3916e1178c1f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# An example hook script to verify what is about to be committed. | |
# Called by "git commit" with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate | |
# message if it wants to stop the commit. | |
# | |
# For branches that follow the following naming it [anything]/[project]/[anything] | |
# or [project]/[anything] it will prepend the project to the commit msg. | |
# | |
# Inspired by https://gist.github.com/bartoszmajsak/1396344/97081e76ab275f5fe526347908503febd1340495 | |
PROJECT_NAME=$(git branch --show-current 2>/dev/null | grep -o -P '([[:alnum:]])+(?=\/)' | tr "\n" " " | awk '{ print ($2 != "")?$2:($1 != "")?$1:"" }') | |
if [ -n "$PROJECT_NAME" ]; then | |
echo "[$PROJECT_NAME] $(cat $1)" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment