Created
June 9, 2021 20:56
-
-
Save joehillen/e34fd3a975beba931af46013ac4b93ba to your computer and use it in GitHub Desktop.
Amend git commits with semversioner changes
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 -ex | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [[ $BRANCH == patch* || $BRANCH == bugfix* ]]; then | |
VER_TYPE=patch | |
elif [[ $BRANCH == feature* || $BRANCH == minor* ]]; then | |
VER_TYPE=minor | |
elif [[ $BRANCH == major* ]]; then | |
VER_TYPE=major | |
else | |
VER_TYPE=$1 | |
fi | |
if [[ $VER_TYPE != "patch" && $VER_TYPE != "minor" && $VER_TYPE != "major" ]]; then | |
echo 'Argument required: Must be "minor", "patch", or "major"' | |
exit 1 | |
fi | |
if [[ ! -f CHANGELOG.md ]]; then | |
cd "$(git rev-parse --show-toplevel)" | |
fi | |
semversioner add-change --type $VER_TYPE --description "$(git --no-pager show -s --format=%s)" | |
git add .changes/next-release/ | |
git commit --amend --no-edit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment