dot

packages and services management
Log | Files | Refs | README

commit 69e49733135a2e52745c26c60463345754e6dbd4
parent bedb43198557e12aa68f377955c12befb714912f
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 29 Jul 2017 23:47:33 +0200

scritps/bin/www-git: added tree generation in awk

Diffstat:
Mscripts/bin/www-git | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/scripts/bin/www-git b/scripts/bin/www-git @@ -11,7 +11,23 @@ cd "git/$NAME" || exit 1 { printf '%s <h1><a href="..">&lt;</a> %s</h1>' "$HEADER" "$NAME" - git -C "$1" ls-files | sed 's|.*|<a href="file/&">&</a>|' + git -C "$1" ls-files | sort | awk -F '\0' '{ + gsub(/&/, "&amp;", $0) + gsub(/</, "$lt;", $0) + + margin = "" + subtree = 0 + count = split($0, line, "/") + for (i = 1; i <= count; i++) { + if (line[i] != prev[i] || subtree) { + subtree + printf "%s`-- <a href=\"%s\">%s</a>\n", margin, line[i], line[i] + } + + margin = margin "| " + prev[i] = line[i] + } + }' "$@" printf '<hr/>\n'