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.

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

Comments   Toot! Share

Last modified: Sunday, April 20, 2008 9:34 pm

Creative Commons Licence BY NC

Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.