Skip to content

Instantly share code, notes, and snippets.

@kennuzzo
Created June 22, 2016 04:12
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 kennuzzo/ad6f01c29179ccd6429c00e5bdafd2f2 to your computer and use it in GitHub Desktop.
Save kennuzzo/ad6f01c29179ccd6429c00e5bdafd2f2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# args=("$@")
# echo Number of arguments: $#
# echo 1st argument: ${args[0]}
# echo 2nd argument: ${args[1]}
# echo without first: ${@:2} $1
# echo $@
# echo $*
function fail()
{
echo Error: "$@" >&2
exit 1
}
function check_for_file()
{
if [ ! -e "$1" ]; then
fail "Missing file: $1"
fi
}
function checkBin()
{
if ! which "$1" >/dev/null; then
fail "missing $1, please install it."
fi
}
checkBin git
checkBin hub
#if [[ $# -eq 0 ]] ; then
# current_commit="$(git log -1 --pretty=%B)"
# echo "using last commit message: $current_commit"
# echo ""
# def_params="-m $current_commit"
# pull_id=`hub pull-request "$def_params"`
#else
# pull_id=`export tty=$(tty) && hub pull-request "$*" < $tty > $tty`
#fi
if [ ! $? -eq 0 ]; then
fail "unable to create pull request."
fi
pull_id=`export tty=$(tty) && hub pull-request "$*" < $tty > $tty`
echo "pullid is: $pull_id"
base="$(basename $pull_id)"
echo "current_commit: $current_commit"
current_amend="( $base ) $current_commit"
echo "amended: current_amend"
git commit --amend -m "$current_amend"
echo "ok ready!, please force push now."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment