Remove use of JSONReader::DeprecatedRead from activity_log
[chromium-blink-merge.git] / tools / git / graph.sh
blob800a52b86c8e2065fa2b07dd47559f5d4a134493
1 #!/bin/bash
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 about="Given a grep expression, creates a graph of occurrences of that
7 expression in the recent history of the tree.
9 Prerequisites: git and GNU R (apt-get install r-base).
12 set -e
14 target="$1"
16 if [ -z $target ]; then
17 echo "usage: $0 <grep-compatible expression>"
18 echo
19 echo "$about"
20 exit 1
23 datafile=$(mktemp -t tmp.XXXXXXXXXX)
24 trap "rm -f $datafile" EXIT
26 echo 'ago count' > $datafile
27 for ago in {90..0}; do
28 commit=$(git rev-list -1 --until="$ago days ago" origin/trunk)
29 git checkout -q -f $commit
30 count=$(git grep -E "$target" -- '*.cc' '*.h' '*.m' '*.mm' | wc -l)
31 echo "-$ago $count" >> $datafile
32 echo -n '.'
33 done
35 R CMD BATCH <(cat <<EOF
36 data = read.delim("$datafile", sep=' ')
37 png(width=600, height=300)
38 plot(count ~ ago, type="l", main="$target", xlab='days ago', data=data)
39 EOF
40 ) /dev/null
42 echo done. # Primarily to add a newline after all the dots.