Added -v (--verbose) flags to list subaction of all subcommands.
This commit is contained in:
parent
c7ea9b2236
commit
3c337fb5e4
5 changed files with 166 additions and 30 deletions
3
git-flow
3
git-flow
|
@ -202,6 +202,9 @@ gitflow_is_branch_merged_into() {
|
||||||
has $BASE $ALL_MERGES
|
has $BASE $ALL_MERGES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# helper functions for common reuse
|
||||||
|
max() { if [ "$1" -gt "$2" ]; then echo "$1"; else echo "$2"; fi; }
|
||||||
|
|
||||||
# convenience functions for checking whether flags have been set or not
|
# convenience functions for checking whether flags have been set or not
|
||||||
flag() { eval FLAG=\$FLAGS_$1; [ $FLAG -eq $FLAGS_TRUE ]; }
|
flag() { eval FLAG=\$FLAGS_$1; [ $FLAG -eq $FLAGS_TRUE ]; }
|
||||||
noflag() { eval FLAG=\$FLAGS_$1; [ $FLAG -ne $FLAGS_TRUE ]; }
|
noflag() { eval FLAG=\$FLAGS_$1; [ $FLAG -ne $FLAGS_TRUE ]; }
|
||||||
|
|
|
@ -28,8 +28,6 @@ cmd_default() {
|
||||||
cmd_list "$@"
|
cmd_list "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
max() { if [ "$1" -gt "$2" ]; then echo "$1"; else echo "$2"; fi; }
|
|
||||||
|
|
||||||
cmd_list() {
|
cmd_list() {
|
||||||
DEFINE_boolean verbose false 'verbose (more) output' v
|
DEFINE_boolean verbose false 'verbose (more) output' v
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
@ -113,7 +111,7 @@ resolve_name_by_prefix() {
|
||||||
|
|
||||||
require_name() {
|
require_name() {
|
||||||
if [ "$NAME" = "" ]; then
|
if [ "$NAME" = "" ]; then
|
||||||
echo "Missing argument <name>"
|
warn "Missing argument <name>"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -17,7 +17,7 @@ PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
|
||||||
FLAG_FETCH=1
|
FLAG_FETCH=1
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: git flow hotfix [list]"
|
echo "usage: git flow hotfix [list] [-v]"
|
||||||
echo " git flow hotfix start <version> [<base>]"
|
echo " git flow hotfix start <version> [<base>]"
|
||||||
echo " git flow hotfix finish <version> [<base>]"
|
echo " git flow hotfix finish <version> [<base>]"
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -37,12 +37,53 @@ cmd_default() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_list() {
|
cmd_list() {
|
||||||
|
DEFINE_boolean verbose false 'verbose (more) output' v
|
||||||
|
parse_args "$@"
|
||||||
|
|
||||||
HOTFIX_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
HOTFIX_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
||||||
if [ -z "$HOTFIX_BRANCHES" ]; then
|
if [ -z "$HOTFIX_BRANCHES" ]; then
|
||||||
warn "No hotfix branches exist."
|
warn "No hotfix branches exist."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "$HOTFIX_BRANCHES" | sed "s?^$PREFIX??g"
|
|
||||||
|
CURRENT_BRANCH=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
|
||||||
|
SHORT_NAMES=$(echo "$HOTFIX_BRANCHES" | sed "s?^$PREFIX??g")
|
||||||
|
# determine column width first
|
||||||
|
width=0
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
len=$(($(echo "$branch" | wc -c) - 1))
|
||||||
|
width=$(max $width $len)
|
||||||
|
done
|
||||||
|
width=$(($width + 3))
|
||||||
|
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
fullname="$PREFIX$branch"
|
||||||
|
base=$(git merge-base "$fullname" "$MASTER_BRANCH")
|
||||||
|
master_sha=$(git rev-parse "$MASTER_BRANCH")
|
||||||
|
branch_sha=$(git rev-parse "$fullname")
|
||||||
|
if [ "$fullname" = "$CURRENT_BRANCH" ]; then
|
||||||
|
printf "* "
|
||||||
|
else
|
||||||
|
printf " "
|
||||||
|
fi
|
||||||
|
if flag verbose; then
|
||||||
|
printf "%-${width}s" "$branch"
|
||||||
|
if [ "$branch_sha" = "$master_sha" ]; then
|
||||||
|
printf "(no commits yet)"
|
||||||
|
else
|
||||||
|
tagname=$(git name-rev --tags --no-undefined --name-only $base)
|
||||||
|
if [ "$tagname" != "" ]; then
|
||||||
|
nicename="$tagname"
|
||||||
|
else
|
||||||
|
nicename="$(git rev-parse --short $base)"
|
||||||
|
fi
|
||||||
|
printf "(based on $nicename)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "%s" "$branch"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_help() {
|
cmd_help() {
|
||||||
|
@ -51,18 +92,22 @@ cmd_help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
# TODO: When we have a nice structured way of parsing flags with getopt,
|
# parse options
|
||||||
# implement the following flags:
|
FLAGS "$@" || exit $?
|
||||||
# --fetch, to set FLAG_FETCH=1
|
eval set -- "${FLAGS_ARGV}"
|
||||||
# --no-fetch, to set FLAG_FETCH=0
|
|
||||||
|
# read arguments into global variables
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
BASE="${2:-$MASTER_BRANCH}"
|
BASE="${2:-$MASTER_BRANCH}"
|
||||||
|
BRANCH=$PREFIX$VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
require_version_arg() {
|
||||||
if [ "$VERSION" = "" ]; then
|
if [ "$VERSION" = "" ]; then
|
||||||
echo "Missing argument <version>."
|
warn "Missing argument <version>"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
BRANCH=$PREFIX$VERSION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_start() {
|
cmd_start() {
|
||||||
|
|
|
@ -17,7 +17,7 @@ PREFIX=$(git config --get gitflow.prefix.release || echo release/)
|
||||||
FLAG_FETCH=1
|
FLAG_FETCH=1
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: git flow release [list]"
|
echo "usage: git flow release [list] [-v]"
|
||||||
echo " git flow release start <version>"
|
echo " git flow release start <version>"
|
||||||
echo " git flow release finish <version>"
|
echo " git flow release finish <version>"
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -38,12 +38,48 @@ cmd_default() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_list() {
|
cmd_list() {
|
||||||
|
DEFINE_boolean verbose false 'verbose (more) output' v
|
||||||
|
parse_args "$@"
|
||||||
|
|
||||||
RELEASE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
RELEASE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
||||||
if [ -z "$RELEASE_BRANCHES" ]; then
|
if [ -z "$RELEASE_BRANCHES" ]; then
|
||||||
warn "No release branches exist."
|
warn "No release branches exist."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "$RELEASE_BRANCHES" | sed "s?^$PREFIX??g"
|
|
||||||
|
CURRENT_BRANCH=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
|
||||||
|
SHORT_NAMES=$(echo "$RELEASE_BRANCHES" | sed "s?^$PREFIX??g")
|
||||||
|
# determine column width first
|
||||||
|
width=0
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
len=$(($(echo "$branch" | wc -c) - 1))
|
||||||
|
width=$(max $width $len)
|
||||||
|
done
|
||||||
|
width=$(($width + 3))
|
||||||
|
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
fullname="$PREFIX$branch"
|
||||||
|
base=$(git merge-base "$fullname" "$DEVELOP_BRANCH")
|
||||||
|
develop_sha=$(git rev-parse "$DEVELOP_BRANCH")
|
||||||
|
branch_sha=$(git rev-parse "$fullname")
|
||||||
|
if [ "$fullname" = "$CURRENT_BRANCH" ]; then
|
||||||
|
printf "* "
|
||||||
|
else
|
||||||
|
printf " "
|
||||||
|
fi
|
||||||
|
if flag verbose; then
|
||||||
|
printf "%-${width}s" "$branch"
|
||||||
|
if [ "$branch_sha" = "$develop_sha" ]; then
|
||||||
|
printf "(no commits yet)"
|
||||||
|
else
|
||||||
|
nicename="$(git rev-parse --short $base)"
|
||||||
|
printf "(based on $nicename)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "%s" "$branch"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_help() {
|
cmd_help() {
|
||||||
|
@ -52,21 +88,26 @@ cmd_help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
# TODO: When we have a nice structured way of parsing flags with getopt,
|
# parse options
|
||||||
# implement the following flags:
|
FLAGS "$@" || exit $?
|
||||||
# --fetch, to set FLAG_FETCH=1
|
eval set -- "${FLAGS_ARGV}"
|
||||||
# --no-fetch, to set FLAG_FETCH=0
|
|
||||||
|
# read arguments into global variables
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
|
BRANCH="$PREFIX$VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
require_version_arg() {
|
||||||
if [ "$VERSION" = "" ]; then
|
if [ "$VERSION" = "" ]; then
|
||||||
echo "Missing argument <version>."
|
warn "Missing argument <version>"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
BRANCH=$PREFIX$VERSION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_start() {
|
cmd_start() {
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
require_version_arg
|
||||||
|
|
||||||
# sanity checks
|
# sanity checks
|
||||||
gitflow_require_clean_working_tree
|
gitflow_require_clean_working_tree
|
||||||
|
@ -95,6 +136,7 @@ cmd_start() {
|
||||||
|
|
||||||
cmd_finish() {
|
cmd_finish() {
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
require_version_arg
|
||||||
|
|
||||||
# sanity checks
|
# sanity checks
|
||||||
gitflow_require_clean_working_tree
|
gitflow_require_clean_working_tree
|
||||||
|
|
|
@ -16,8 +16,11 @@ VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
|
||||||
PREFIX=$(git config --get gitflow.prefix.support || echo support/)
|
PREFIX=$(git config --get gitflow.prefix.support || echo support/)
|
||||||
FLAG_FETCH=1
|
FLAG_FETCH=1
|
||||||
|
|
||||||
|
warn "note: The support subcommand is still very EXPERIMENTAL!"
|
||||||
|
warn "note: DO NOT use it in a production situation."
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: git flow support [list]"
|
echo "usage: git flow support [list] [-v]"
|
||||||
echo " git flow support start <version> [<base>]"
|
echo " git flow support start <version> [<base>]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +29,53 @@ cmd_default() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_list() {
|
cmd_list() {
|
||||||
|
DEFINE_boolean verbose false 'verbose (more) output' v
|
||||||
|
parse_args "$@"
|
||||||
|
|
||||||
SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
SUPPORT_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")"
|
||||||
if [ -z "$SUPPORT_BRANCHES" ]; then
|
if [ -z "$SUPPORT_BRANCHES" ]; then
|
||||||
warn "No support branches exist."
|
warn "No support branches exist."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g"
|
|
||||||
|
CURRENT_BRANCH=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
|
||||||
|
SHORT_NAMES=$(echo "$SUPPORT_BRANCHES" | sed "s?^$PREFIX??g")
|
||||||
|
# determine column width first
|
||||||
|
width=0
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
len=$(($(echo "$branch" | wc -c) - 1))
|
||||||
|
width=$(max $width $len)
|
||||||
|
done
|
||||||
|
width=$(($width + 3))
|
||||||
|
|
||||||
|
for branch in $SHORT_NAMES; do
|
||||||
|
fullname="$PREFIX$branch"
|
||||||
|
base=$(git merge-base "$fullname" "$MASTER_BRANCH")
|
||||||
|
master_sha=$(git rev-parse "$MASTER_BRANCH")
|
||||||
|
branch_sha=$(git rev-parse "$fullname")
|
||||||
|
if [ "$fullname" = "$CURRENT_BRANCH" ]; then
|
||||||
|
printf "* "
|
||||||
|
else
|
||||||
|
printf " "
|
||||||
|
fi
|
||||||
|
if flag verbose; then
|
||||||
|
printf "%-${width}s" "$branch"
|
||||||
|
if [ "$branch_sha" = "$master_sha" ]; then
|
||||||
|
printf "(no commits yet)"
|
||||||
|
else
|
||||||
|
tagname=$(git name-rev --tags --no-undefined --name-only $base)
|
||||||
|
if [ "$tagname" != "" ]; then
|
||||||
|
nicename="$tagname"
|
||||||
|
else
|
||||||
|
nicename="$(git rev-parse --short $base)"
|
||||||
|
fi
|
||||||
|
printf "(based on $nicename)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "%s" "$branch"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_help() {
|
cmd_help() {
|
||||||
|
@ -40,22 +84,27 @@ cmd_help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
# TODO: When we have a nice structured way of parsing flags with getopt,
|
# parse options
|
||||||
# implement the following flags:
|
FLAGS "$@" || exit $?
|
||||||
# --fetch, to set FLAG_FETCH=1
|
eval set -- "${FLAGS_ARGV}"
|
||||||
# --no-fetch, to set FLAG_FETCH=0
|
|
||||||
|
# read arguments into global variables
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
BASE="${2:-${VERSION_PREFIX}${VERSION}}"
|
BASE="${2:-${VERSION_PREFIX}${VERSION}}"
|
||||||
|
BRANCH=$PREFIX$VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
require_version_arg() {
|
||||||
if [ "$VERSION" = "" ]; then
|
if [ "$VERSION" = "" ]; then
|
||||||
echo "Missing argument <version>."
|
warn "Missing argument <version>"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
BRANCH=$PREFIX$VERSION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_start() {
|
cmd_start() {
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
require_version_arg
|
||||||
|
|
||||||
# sanity checks
|
# sanity checks
|
||||||
gitflow_require_clean_working_tree
|
gitflow_require_clean_working_tree
|
||||||
|
@ -64,13 +113,12 @@ cmd_start() {
|
||||||
if [ $FLAG_FETCH -eq 1 ]; then
|
if [ $FLAG_FETCH -eq 1 ]; then
|
||||||
git fetch -q $ORIGIN $BASE
|
git fetch -q $ORIGIN $BASE
|
||||||
fi
|
fi
|
||||||
gitflow_require_branches_equal $BRANCH $ORIGIN/$BRANCH
|
|
||||||
|
|
||||||
# create branch
|
# create branch
|
||||||
git checkout -b $BRANCH $BASE
|
git checkout -b "$BRANCH" "$BASE"
|
||||||
|
|
||||||
# publish branch
|
# publish branch
|
||||||
git push $ORIGIN $BRANCH:refs/heads/$BRANCH
|
#git push $ORIGIN $BRANCH:refs/heads/$BRANCH
|
||||||
|
|
||||||
git config branch.$BRANCH.remote $ORIGIN
|
git config branch.$BRANCH.remote $ORIGIN
|
||||||
git config branch.$BRANCH.merge refs/heads/$BRANCH
|
git config branch.$BRANCH.merge refs/heads/$BRANCH
|
||||||
|
|
Loading…
Reference in a new issue