getting some stats from svn
I wanted to measure the progress of a svn repository, and i noticed a lack of stats generator tools for subversion, so i made a little (magic) script...
An example of the output:
[Update: when you delete a whole directory with files that information doesn't go to the svn diff output, so sometimes the delta is a wrong :( ]
Rev date (timet) username line delta 64 1119161309 juan -153 65 1119161512 juan 132 66 1119161874 juan 3 67 1119162035 juan 130 68 1119162306 juan 15
#
# Copyright (c) 2005 Juan F. Codagnone <juam-AT-users-DOT-sourceforge-DOT-net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# shows svn (subversion) statics
# the ouput format is:
# revision date user delta_lines
# where
# date is represented as a time_t
# delta lines the lines you added minus the one you removed
#repo=file:///home/prueba/a/repo/
if [[ $# == 1 ]]; then
repo=$1
else
echo "Usage: $0 url"
echo
echo "for example: $0 file:///home/test/repo/"
exit
fi
rev=`svn info $repo|grep ^Revision:|cut -d' ' -f2`
for i in `seq 1 $rev`
do
# extract date to YYYY MM DD HH MM SS
date=`svn info -r$i $repo|grep "^Last Changed Date"|cut -b20-38|
sed -e"s/-/ /g" -e"s/:/ /g" `
# convert it to time_t
date=`echo|awk '{print mktime("'"$date"'")}'`
echo -n "$i $date "
echo -n `svn info -r$i $repo|grep '^Last Changed Author:'|cut -d: -f2`
echo -n " "
# change line
svn diff -r$(($i-1)):$i $repo | diffstat | tail -n1|awk '{print $4 - $6 }'
done
0 comments