From b32c7a3d45046e7d0d7d0abdcfabffc1295c6935 Mon Sep 17 00:00:00 2001 From: Alexey Alekhin Date: Thu, 20 Feb 2014 16:35:17 +0100 Subject: [PATCH] Imlemented tree command to show the global structure of tasks/branches; added base info to gtm-info --- gtm | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/gtm b/gtm index b3a0ca3..255558b 100755 --- a/gtm +++ b/gtm @@ -8,7 +8,7 @@ # GNU General Public License version 3 or any later version, incorporated # herein by reference. -VERSION="0.7.5" +VERSION="0.8.0" export GIT_NOTES_DISPLAY_REF="refs/notes/timetracker" @@ -92,6 +92,7 @@ gtm v$VERSION - git task/time manager (c) Alexey Alekhin `bold 'Information commands'`: `green list` -- list all tasks with issue numbers and timers information + `green tree` -- prints the tree of branches with respect to their base branches `green log` -- same as git-log but with human-format time notes `green summary` -- print summary of spent time by authors `green report` [options] -- print list of commits with time information and summary @@ -425,6 +426,31 @@ function gtm_list() { done } +function full_name() { + local br="$1" # branch name + local acc="$2" # accumulated full name + local base="$(git config branch.$br.base)" + if [ ! "$base" ]; then + git config branch.$br.base master + base="master" + fi + if [ "$br" == "master" ]; then echo "$br:$acc" + else full_name "$base" "$br:$acc" + fi +} + +function gtm_tree() { + local branches=$(git for-each-ref refs/heads/ --format='%(refname:short)') + # local branches=$(git config --get-regexp "^branch.*.base" | cut -d . -f 2) + local current_branch=$(current_branch) + local list=$(for branch in $branches; do echo $(full_name $branch); done | sort) + for br in $list; do + local cutbr=${br%:} + echo -n $cutbr | sed 's/[^:]\+:\([^:]\+\)$/└── \1/g' | sed 's/[^:]\+:/ /g' + [ "${cutbr##*:}" == "$(current_branch)" ] && echo " *" || echo + done +} + function gtm_summary() { local alltimes=$(git log --format="%N" | grep "Time-spent:" | sed 's/ *Time-spent: *//') local allusers=$(git log --format="%ae" | sort | uniq) @@ -990,7 +1016,7 @@ Shows issue which is bound to the current task. See possible options in `blue 'g " case $1 in -h|--help) echo "$help_msg" && exit ;; esac - echo "Task `blue "[$(current_branch)]"`: `gtm_status`" + echo "Task `blue "[$(current_branch)]"` from `red "[$(git config branch.$(current_branch).base)]"`: `gtm_status`" echo local issue=$(git config branch.$(current_branch).issue) [ ! "$issue" ] && err "No issue is bound to the task. See 'gtm help connect'" @@ -1124,6 +1150,9 @@ case $subcommand in list) gtm_list "$@" ;; + tree) + gtm_tree "$@" + ;; undo) gtm_undo "$@" ;;