From 258cb7979e364483d6910acef474377decc9fcb8 Mon Sep 17 00:00:00 2001 From: Jake Zimmerman Date: Thu, 11 Jan 2018 00:44:19 -0800 Subject: [PATCH] Add --filter flag The normal approach to filtering would be to just use Unix pipes. That strategy doesn't work well here, because the histogram max width is determined by the line with the most commits. So if one file has been changed 1000 times and all the rest are orders of magnitude smaller, the bar chart will have a lot of unused space. --- git-heatmap | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/git-heatmap b/git-heatmap index 8391a12..daf6b35 100755 --- a/git-heatmap +++ b/git-heatmap @@ -31,6 +31,11 @@ while [[ $# -gt 0 ]]; do shift shift ;; + -f|--filter) + FILTER="$2" + shift + shift + ;; -h) cat <, --base Compare relative to . If on , show heatmap for entire repo. [default: master] -c , --char Use to draw the bars. [default: █] + -f , --filter Filter output through before creating the + the histogram. -h Show this message. EOF exit @@ -59,6 +66,7 @@ LIMIT=${LIMIT:-30} REVIEW_BASE=${REVIEW_BASE:-master} CHAR=${CHAR:-█} WIDTH=${WIDTH:-60} +FILTER=${FILTER:-cat -} files() { # https://stackoverflow.com/questions/7577052/ @@ -76,6 +84,7 @@ color_name() { filter() { grep '.' | \ + eval "$FILTER" | \ sort | \ uniq -c | \ sort -nr | \