• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
5
6about="Given a grep expression, creates a graph of occurrences of that
7expression in the recent history of the tree.
8
9Prerequisites: git and GNU R (apt-get install r-base).
10"
11
12set -e
13
14target="$1"
15
16if [ -z $target ]; then
17    echo "usage: $0 <grep-compatible expression>"
18    echo
19    echo "$about"
20    exit 1
21fi
22
23datafile=$(mktemp -t tmp.XXXXXXXXXX)
24trap "rm -f $datafile" EXIT
25
26echo 'ago count' > $datafile
27for 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 '.'
33done
34
35R CMD BATCH <(cat <<EOF
36data = read.delim("$datafile", sep=' ')
37png(width=600, height=300)
38plot(count ~ ago, type="l", main="$target", xlab='days ago', data=data)
39EOF
40) /dev/null
41
42echo done.  # Primarily to add a newline after all the dots.
43