Last active
December 11, 2023 17:40
-
-
Save kmwalsh/a9138fda09d3d43d26f364a659054e08 to your computer and use it in GitHub Desktop.
automatically prepend ticket number to commit message
This file contains 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
* mv .git/hooks/commit-msg.sample .git/hooks/commit-msg | |
* chmod ug+x .git/hooks/commit-msg | |
paste the desired script into commit-msg |
This file contains 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 | |
# branch structure of `something/####-something` | |
ticket=$(git symbolic-ref HEAD | awk -F"[/-]" '{print $4}') | |
if [ -n "$ticket" ]; then | |
echo $ticket":" "$(cat $1)" > $1 | |
fi |
This file contains 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 | |
# branch structure of `SOMETHING-####-SOMETHING` | |
ticket=$(git symbolic-ref HEAD | awk -F"[--]" '{print $2}') | |
if [ -n "$ticket" ]; then | |
echo $ticket":" "$(cat $1)" > $1 | |
fi |
This file contains 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 | |
# branch structure of `something/something/SOMETHING` | |
ticket=$(git symbolic-ref HEAD | awk -F "/" '{print $NF}') | |
if [ -n "$ticket" ]; then | |
echo $ticket":" "$(cat $1)" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment