Add git-finish subcommand, to automate the process of finishing feature and hotfix branches the way I like

This commit is contained in:
Danielle McLean 2017-10-06 15:10:55 +11:00
parent 1545df64a9
commit 7b32331bd2
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

21
local/bin/git-finish Executable file
View file

@ -0,0 +1,21 @@
#!/bin/zsh
branch=$1
branchParts=( ${(s:/:)branch} )
kind=$branchParts[1]
name=$branchParts[2]
echo "Finishing $kind '$name'..." >&2
git checkout $branch || exit $?
merge-into() {
echo "Merging $branch into $1..." >&2
git checkout $1 || exit $?
git merge --no-ff $branch --message "Merge $kind '$name' into $1" || exit $?
}
[[ $kind = hotfix ]] && merge-into master
merge-into develop
echo "Merge successful, deleting $branch..." >&2
git push origin --delete $branch || exit $?
git branch --delete $branch