Created
March 22, 2022 08:38
-
-
Save suTerminus/2ab666c5f614f136221ce368e5c0e577 to your computer and use it in GitHub Desktop.
small script which uses branch names to automatically set "<type>[optional scope]" according to conventional commit guidelines.
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/bash | |
| if [ -z "$2" ] | |
| then | |
| t=$(git branch --show-current | awk -F/ '{$NF=""} 1' | awk '{s=($1=="fix" || $1=="hotfix")?"fix":"feat";print s;}') | |
| m=$1 | |
| else | |
| t=$1 | |
| m=$2 | |
| fi | |
| i=$(git branch --show-current | awk -F/ '{print $2}' | awk -F- '{print $1"-"$2}') | |
| fm="$t($i):$m" | |
| echo $fm | |
| git commit -m $fm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment