Commit 0a5c7307 authored by Vincent Driessen's avatar Vincent Driessen

Merge branch 'feature/verbose-feature-list' into develop

parents 60d3d62f 1adbc3e9
...@@ -40,6 +40,8 @@ cmd_default() { ...@@ -40,6 +40,8 @@ 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 0 'verbose (more) output' v DEFINE_boolean verbose 0 'verbose (more) output' v
parse_args "$@" parse_args "$@"
...@@ -49,7 +51,37 @@ cmd_list() { ...@@ -49,7 +51,37 @@ cmd_list() {
warn "No feature branches exist." warn "No feature branches exist."
exit 0 exit 0
fi fi
echo "$FEATURE_BRANCHES" | sed "s?^$PREFIX??g"
SHORT_NAMES=$(echo "$FEATURE_BRANCHES" | sed "s?^$PREFIX??g")
if [ $FLAGS_verbose -eq 0 ]; then
echo "$SHORT_NAMES"
else
# 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")
printf "%-${width}s" "$branch"
if [ "$branch_sha" = "$develop_sha" ]; then
printf "(no commits yet)"
elif [ "$base" = "$branch_sha" ]; then
printf "(is behind develop, may ff)"
elif [ "$base" = "$develop_sha" ]; then
printf "(based on latest develop)"
else
printf "(may be rebased)"
fi
echo
done
fi
} }
cmd_help() { cmd_help() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment