Skip to content

Instantly share code, notes, and snippets.

@blendsdk
Created February 24, 2016 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blendsdk/dc9cf3a7a051c98e8887 to your computer and use it in GitHub Desktop.
Save blendsdk/dc9cf3a7a051c98e8887 to your computer and use it in GitHub Desktop.
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m'
cur_branch_name=$(git symbolic-ref -q HEAD)
cur_branch_name=${cur_branch_name##refs/heads/}
cur_branch_name=${cur_branch_name:-HEAD}
cache=~/bin
reponame=$(basename $(git rev-parse --show-toplevel))
mkdir -p $cache
if [ "$1" = "--close" ]; then
if [ -f $latest ]; then
$latest
rm -f $latest
else
echo -e "\e[41mNothing to close!\e[0m";
fi
exit;
fi
if [ -n "$1" ]; then
close_script=$cache/close-${reponame,,}-$1.sh
echo -e "\e[45mBranching from ${cur_branch_name} -> ${1}\e[0m";
git checkout -b $1
echo -e "git add ." > $close_script
echo -e "git commit -a -m\"closed by git-feature.\"" >> $close_script;
echo -e "git checkout ${cur_branch_name}" >> $close_script;
echo -e "git merge --no-ff ${1}" >> $close_script
echo -e "git branch -d ${1}" >> $close_script
echo -e "rm -- $close_script" >> $close_script
echo -e "\e[44mTo close use [${close_script}]\e[0m";
chmod +x $close_script
else
echo -e "\e[41mPlease provide a new feature name!\e[0m";
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment