Created
August 25, 2022 10:43
-
-
Save giuscri/26fe7caf8057eed8227ea9258f6d589f 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
# Returns HEAD commit message formatted as a valid branch name | |
msg2bname() { | |
git show -s --format=%s | tr '(' '_' | tr -d '):' | tr ' ' '-' # chore(k8s): create secret -> chore_k8s-create-secret | |
# chore: use correct db password -> chore-use-correct-db-password | |
} | |
# Returns branch name formatted as a commit message | |
bname2msg() { | |
bname=$(git branch --show-current) | |
if [[ $(echo $bname | grep '(') ]]; then | |
echo $bname | sed 's,_\([^-]*\),(\1):,' | tr '-' ' ' # chore_k8s-create-secret -> chore(k8s): create secret | |
else | |
echo $bname | sed 's,-,: ,' | tr '-' ' ' # chore-use-correct-db-password -> chore: use correct db password | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment