mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Add ability to specify a remote
Use -r to push the new branch to origin Use -r <remote_name> to push to <remote_name> Will not auto push to origin if you do not use the argument
This commit is contained in:
parent
be15db9cdf
commit
61b2a2c703
61
bin/git-bug
61
bin/git-bug
|
|
@ -1,14 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if test "$1" = "finish"; then
|
||||
test -z $2 && echo "bug <name> required." 1>&2 && exit 1
|
||||
branch=bug/$2
|
||||
git merge --no-ff $branch && git delete-branch $branch
|
||||
branch_prefix=bug
|
||||
declare -a argv
|
||||
while test $# != 0
|
||||
do
|
||||
case $1 in
|
||||
-a|--alias )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
shift # shift -a|-alias
|
||||
branch_prefix=$1
|
||||
else
|
||||
argv+=($1) # treat tail '-a' as <name>
|
||||
fi
|
||||
;;
|
||||
-r|--remote )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
remote=$2
|
||||
shift
|
||||
else
|
||||
remote="origin"
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
argv+=($1)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
concatargs(){
|
||||
str=$(IFS='-'; echo "$*")
|
||||
branch="$branch_prefix"/$str
|
||||
}
|
||||
|
||||
if test "${argv[0]}" = "finish"; then
|
||||
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
branch="$branch_prefix"/"${argv[1]}"
|
||||
git merge --no-ff "$branch" && git delete-branch "$branch"
|
||||
else
|
||||
test -z $1 && echo "bug <name> required." 1>&2 && exit 1
|
||||
if test -n "$2"; then
|
||||
echo "too many arguments; if not finishing a bug, only <name> of new bug is expected" && exit 1
|
||||
fi
|
||||
branch=bug/$1
|
||||
git create-branch $branch
|
||||
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
if test -n "${argv[1]}"; then
|
||||
concatargs "${argv[@]}"
|
||||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
if [[ -n $remote ]]
|
||||
then
|
||||
git create-branch -r $remote $branch
|
||||
else
|
||||
git create-branch $branch
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,14 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if test "$1" = "finish"; then
|
||||
test -z $2 && echo "chore <name> required." 1>&2 && exit 1
|
||||
branch=chore/$2
|
||||
git merge --no-ff $branch && git delete-branch $branch
|
||||
branch_prefix=chore
|
||||
declare -a argv
|
||||
while test $# != 0
|
||||
do
|
||||
case $1 in
|
||||
-a|--alias )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
shift # shift -a|-alias
|
||||
branch_prefix=$1
|
||||
else
|
||||
argv+=($1) # treat tail '-a' as <name>
|
||||
fi
|
||||
;;
|
||||
-r|--remote )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
remote=$2
|
||||
shift
|
||||
else
|
||||
remote="origin"
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
argv+=($1)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
concatargs(){
|
||||
str=$(IFS='-'; echo "$*")
|
||||
branch="$branch_prefix"/$str
|
||||
}
|
||||
|
||||
if test "${argv[0]}" = "finish"; then
|
||||
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
branch="$branch_prefix"/"${argv[1]}"
|
||||
git merge --no-ff "$branch" && git delete-branch "$branch"
|
||||
else
|
||||
test -z $1 && echo "chore <name> required." 1>&2 && exit 1
|
||||
if test -n "$2"; then
|
||||
echo "too many arguments; if not finishing a chore, only <name> of new chore is expected" && exit 1
|
||||
fi
|
||||
branch=chore/$1
|
||||
git create-branch $branch
|
||||
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
if test -n "${argv[1]}"; then
|
||||
concatargs "${argv[@]}"
|
||||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
if [[ -n $remote ]]
|
||||
then
|
||||
git create-branch -r $remote $branch
|
||||
else
|
||||
git create-branch $branch
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
branch=$1
|
||||
test -z $branch && echo "branch required." 1>&2 && exit 1
|
||||
for param in $*
|
||||
do
|
||||
case $param in
|
||||
-r|--remote)
|
||||
if [ $# -eq 2 ]
|
||||
then
|
||||
BRANCH=$2
|
||||
else
|
||||
REMOTE=$2
|
||||
BRANCH=$3
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
BRANCH=$param
|
||||
esac
|
||||
done
|
||||
|
||||
test -z $BRANCH && echo "branch required." 1>&2 && exit 1
|
||||
if [[ -n $REMOTE ]]
|
||||
then
|
||||
git ls-remote --exit-code $REMOTE &>/dev/null
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
git push $REMOTE HEAD:refs/heads/$BRANCH
|
||||
git fetch $REMOTE
|
||||
git checkout --track -b $BRANCH $REMOTE/$BRANCH
|
||||
else
|
||||
git checkout -b $BRANCH
|
||||
fi
|
||||
else
|
||||
git checkout -b $BRANCH
|
||||
fi
|
||||
|
||||
git push origin HEAD:refs/heads/$branch
|
||||
git fetch origin
|
||||
git checkout --track -b $branch origin/$branch
|
||||
|
|
|
|||
|
|
@ -14,6 +14,15 @@ do
|
|||
argv+=($1) # treat tail '-a' as <name>
|
||||
fi
|
||||
;;
|
||||
-r|--remote )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
remote=$2
|
||||
shift
|
||||
else
|
||||
remote="origin"
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
argv+=($1)
|
||||
;;
|
||||
|
|
@ -27,15 +36,20 @@ concatargs(){
|
|||
}
|
||||
|
||||
if test "${argv[0]}" = "finish"; then
|
||||
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
branch="$branch_prefix"/"${argv[1]}"
|
||||
git merge --no-ff "$branch" && git delete-branch "$branch"
|
||||
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
branch="$branch_prefix"/"${argv[1]}"
|
||||
git merge --no-ff "$branch" && git delete-branch "$branch"
|
||||
else
|
||||
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
if test -n "${argv[1]}"; then
|
||||
concatargs "${argv[@]}"
|
||||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
git create-branch $branch
|
||||
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
if test -n "${argv[1]}"; then
|
||||
concatargs "${argv[@]}"
|
||||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
if [[ -n $remote ]]
|
||||
then
|
||||
git create-branch -r $remote $branch
|
||||
else
|
||||
git create-branch $branch
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,14 +1,56 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if test "$1" = "finish"; then
|
||||
test -z $2 && echo "refactor <name> required." 1>&2 && exit 1
|
||||
branch=refactor/$2
|
||||
git merge --no-ff $branch && git delete-branch $branch
|
||||
branch_prefix=refactor
|
||||
declare -a argv
|
||||
while test $# != 0
|
||||
do
|
||||
case $1 in
|
||||
-a|--alias )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
shift # shift -a|-alias
|
||||
branch_prefix=$1
|
||||
else
|
||||
argv+=($1) # treat tail '-a' as <name>
|
||||
fi
|
||||
;;
|
||||
-r|--remote )
|
||||
if [[ -n $2 ]]
|
||||
then
|
||||
remote=$2
|
||||
shift
|
||||
else
|
||||
remote="origin"
|
||||
fi
|
||||
;;
|
||||
* )
|
||||
argv+=($1)
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
concatargs(){
|
||||
str=$(IFS='-'; echo "$*")
|
||||
branch="$branch_prefix"/$str
|
||||
}
|
||||
|
||||
if test "${argv[0]}" = "finish"; then
|
||||
test -z "${argv[1]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
branch="$branch_prefix"/"${argv[1]}"
|
||||
git merge --no-ff "$branch" && git delete-branch "$branch"
|
||||
else
|
||||
test -z $1 && echo "refactor <name> required." 1>&2 && exit 1
|
||||
if test -n "$2"; then
|
||||
echo "too many arguments; if not finishing a refactor, only <name> of new refactoring is expected" && exit 1
|
||||
fi
|
||||
branch=refactor/$1
|
||||
git create-branch $branch
|
||||
test -z "${argv[0]}" && echo "$branch_prefix" "<name> required." 1>&2 && exit 1
|
||||
if test -n "${argv[1]}"; then
|
||||
concatargs "${argv[@]}"
|
||||
else
|
||||
branch="$branch_prefix"/"${argv[0]}"
|
||||
fi
|
||||
if [[ -n $remote ]]
|
||||
then
|
||||
git create-branch -r $remote $branch
|
||||
else
|
||||
git create-branch $branch
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue