From 55578f0151f8c274a8a1fc0cf62e0220bc722d81 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 16 Oct 2008 12:35:16 +0200 Subject: [PATCH] tg summary --graphviz: Dot-suitable dependency graph Inspired by Antonio Ospite 's tg-graphviz.sh. --- README | 6 ++++-- tg-summary.sh | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README b/README index dbf12ed..ece1d02 100644 --- a/README +++ b/README @@ -333,10 +333,12 @@ tg summary This can take long time to accurately determine all the relevant information about each branch; you can pass '-t' to get just - terse list of topic branch names quickly. + terse list of topic branch names quickly. Alternately, you can + pass '--graphviz' to get a dot-suitable output to draw a dependency + graph between the topic branches. TODO: Speed up by an order of magnitude - TODO: Graph view + TODO: Text graph view tg export ~~~~~~~~~ diff --git a/tg-summary.sh b/tg-summary.sh index 3905bdc..3c90a6b 100644 --- a/tg-summary.sh +++ b/tg-summary.sh @@ -4,6 +4,7 @@ # GPLv2 terse= +graphviz= ## Parse options @@ -13,14 +14,36 @@ while [ -n "$1" ]; do case "$arg" in -t) terse=1;; + --graphviz) + graphviz=1;; *) - echo "Usage: tg [...] summary [-t]" >&2 + echo "Usage: tg [...] summary [-t | --graphviz]" >&2 exit 1;; esac done curname="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')" +if [ -n "$graphviz" ]; then + cat < +# or +# | dot -Txlib + +digraph G { + +graph [ + rankdir = "TB" + label="TopGit Layout\n\n\n" + fontsize = 14 + labelloc=top + pad = "0.5,0.5" +]; + +EOT +fi + ## List branches @@ -31,6 +54,12 @@ git for-each-ref refs/top-bases | echo "$name" continue fi + if [ -n "$graphviz" ]; then + git cat-file blob "$name:.topdeps" | while read dep; do + echo "\"$name\" -> \"$dep\";" + done + continue + fi missing_deps= @@ -65,3 +94,7 @@ git for-each-ref refs/top-bases | printf '%s\t%-31s\t%s\n' "$current$nonempty$remote$rem_update$deps_update$deps_missing$base_update" \ "$name" "$subject" done + +if [ -n "$graphviz" ]; then + echo '}' +fi -- 2.30.2