blog dds

2008.04.20

Assigning Responsibility

Over the past few days I worked over a large code body correcting various accumulated errors and style digressions. When I finished I wanted to see who wrote the original lines. (It turned out I was not entirely innocent.)

I therefore wrote the following shell script. When run in a local CVS directory with uncommitted code it will go through all changed lines and will assign those lines to the last persons who edited them. It will then report how many of those fixed lines were written by each developer.

#!/bin/sh
# Obtain modified files and line numbers
cvs diff -rHEAD "--old-line-format=%dn%c'\012'" --new-line-format= --unchanged-line-format= |
sed -n '
1i\
echo '\''
# Run cvs annotate on each file
/^diff/ {
	s/.* /cvs annotate /
	s/$/ |\
awk '\''\
/
	p
}
# For each changed line print the name of its last committer
/^[0-9]/ {
	s/^/FNR == /
	s/$/ {print substr($2, 2, 256) }/
	p
}
# Terminate the awk scripts
$a\
'\''
/^Index/a\
'\''' |
sh |
sort |
uniq -c
I love shell scripts.

Read and post comments    AddThis Social Bookmark Button


Creative Commons License Last modified: Sunday, April 20, 2008 9:34 pm
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.