Skip to content

Instantly share code, notes, and snippets.

@fyrchik
Last active February 24, 2022 10:46
Show Gist options
  • Save fyrchik/0c7075d03f4bfe3a7665e98f9100efdb to your computer and use it in GitHub Desktop.
Save fyrchik/0c7075d03f4bfe3a7665e98f9100efdb to your computer and use it in GitHub Desktop.
Prepare commit in accordance with NSPCC format
#!/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