dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

loc.sh (1643B)


      1 #!/bin/sh
      2 
      3 # count (rough) LOC from a git repository.
      4 # writes to the files loc.csv and loc.png.
      5 
      6 #ISC License
      7 #
      8 #Copyright (c) 2011-2018 Hiltjo Posthuma <hiltjo@codemadness.org>
      9 #
     10 #Permission to use, copy, modify, and/or distribute this software for any
     11 #purpose with or without fee is hereby granted, provided that the above
     12 #copyright notice and this permission notice appear in all copies.
     13 #
     14 #THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     15 #WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     16 #MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     17 #ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     18 #WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     19 #ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     20 #OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     21 
     22 # group by day
     23 git log --pretty='format:%H %cd' --date="format:%Y-%m-%d" | sort -k 2 | uniq -f 1 | while read -r commit date; do
     24 	printf '%s\t%s\t' "$date" "$commit"
     25 	git ls-tree --name-only -r "$commit" | grep -E 'Makefile|\.(c|h|sh|mk|cpp|cc|hh|js|css)$' | while read -r file; do
     26 		git show "$commit:$file" | wc -l
     27 	done | awk '{ l += int($0) } END { print l }'
     28 done | tee loc.csv
     29 
     30 # plot using GNU plot.
     31 
     32 gnuplot - <<__EOF__
     33 set term png
     34 set output "loc.png"
     35 
     36 set title "bloooat"
     37 set xlabel "Commit date"
     38 set ylabel "LOC"
     39 
     40 set xdata time
     41 set format x "%Y-%m"
     42 set timefmt "%Y-%m-%dT%H:%M:%S"
     43 
     44 set xtics 2592000
     45 set xtic rotate by 90 scale 0 right font ",8"
     46 plot 'loc.csv' using 1:3 with lp notitle pointtype 5 pointsize 0.3
     47 
     48 __EOF__
     49 
     50 xdg-open loc.png