Last active
February 24, 2022 10:46
-
-
Save fyrchik/0c7075d03f4bfe3a7665e98f9100efdb to your computer and use it in GitHub Desktop.
Prepare commit in accordance with NSPCC format
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 | |
if [ -z "$1" ]; then | |
echo "Issue must be provided." | |
exit 1 | |
fi | |
ISSUE="[#$1]" | |
BRANCH=${2:-master} | |
BASE=$(git merge-base HEAD "$BRANCH") | |
# Note: \U is a GNU sed extension. | |
export GIT_EDITOR="sed -i -E -e '1 s/^[^[].*/$ISSUE \0/' -e '1 s/: [a-z]/\U\0/'" | |
git rebase "$BASE" --exec "git commit --amend --signoff --allow-empty" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment