Skip to content

Instantly share code, notes, and snippets.

@coffeesam
Created September 20, 2017 06:11
Show Gist options
  • Save coffeesam/d04311297707279806cd2bd3b8905402 to your computer and use it in GitHub Desktop.
Save coffeesam/d04311297707279806cd2bd3b8905402 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
##############################################################################
# MIT License (MIT)
# Copyright © 2017 Silicon Jungles Pte Ltd
#
# git-flow-feature-close: merge squash feature commits to develop.
#
# References:
#
##############################################################################
get_branch_name() {
if git_repository_exists; then
echo "$(git branch | grep '\*' | cut -d ' ' -f2)"
fi
}
confirm() {
printf "Are you sure you want to proceed [Yes/No]? "
read -r response;
case $response in
[yY]*)
return 0;
;;
*)
return 1;
esac
}
if [ -z $1 ]; then
echo No commit message given. Aborting...
echo
exit
fi
echo This will squash all new commits on $(get_branch_name) on develop.
if confirm; then
FEATURE_BRANCH=get_branch_name
git checkout develop
echo "Syncing develop branch..."
git pull origin develop
echo "Develop branch is synced. Squashing feature commits and rebased on develop..."
git merge --squash $FEATURE_BRANCH
git commit -m $1
echo Feature branch rebase squash is complete. Ready to push.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment