File tree Expand file tree Collapse file tree 1 file changed +31
-14
lines changed
Expand file tree Collapse file tree 1 file changed +31
-14
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3+ branch_prefix=feature
4+ declare -a argv
5+ while test $# ! = 0
6+ do
7+ case $1 in
8+ -a|--alias )
9+ if [[ -n $2 ]]
10+ then
11+ shift # shift -a|-alias
12+ branch_prefix=$1
13+ else
14+ argv+=($1 ) # treat tail '-a' as <name>
15+ fi
16+ ;;
17+ * )
18+ argv+=($1 )
19+ ;;
20+ esac
21+ shift
22+ done
23+
324concatargs (){
4- delim=' -'
5- str=
6- for i in " $@ " ; do
7- str=" $str$delim$i "
8- done
9- branch=feature/${str: 1}
25+ str=$( IFS=' -' ; echo " $* " )
26+ branch=" $branch_prefix " /$str
1027}
1128
12- if test " $1 " = " finish" ; then
13- test -z $2 && echo " feature <name> required." 1>&2 && exit 1
14- branch=feature/ $2
15- git merge --no-ff $branch && git delete-branch $branch
29+ if test " ${argv[0]} " = " finish" ; then
30+ test -z " ${argv[1]} " && echo " $branch_prefix " " <name> required." 1>&2 && exit 1
31+ branch=" $branch_prefix " / " ${argv[1]} "
32+ git merge --no-ff " $branch " && git delete-branch " $branch "
1633else
17- test -z $1 && echo " feature <name> required." 1>&2 && exit 1
18- if test -n " $2 " ; then
19- concatargs ${ @: 2}
34+ test -z " ${argv[0]} " && echo " $branch_prefix " " <name> required." 1>&2 && exit 1
35+ if test -n " ${argv[1]} " ; then
36+ concatargs " ${argv[@]} "
2037 else
21- branch=feature/ $1
38+ branch=" $branch_prefix " / " ${argv[0]} "
2239 fi
2340 git checkout -b $branch
2441fi
You can’t perform that action at this time.
0 commit comments