-
-
Save nikku/4a4c0b7848bd78afc457 to your computer and use it in GitHub Desktop.
A small utility script that computes Java code metrics over a series of versions (in terms of git tags or commits).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
src_dir=$1 | |
test_dir=$2 | |
commits=`cat $3` | |
commits_count=`echo $commits | wc -w` | |
dest_file=$4 | |
printf "Writing metrics for %s commits into %s\n src_dir: %s\n test_dir: %s\n" $tag_count $dest_file $src_dir $test_dir | |
count=0 | |
for commit in $commits | |
do | |
printf "." | |
# checkout | |
git checkout -q $commit | |
src_files=$(find $src_dir -type f -name '*.java' | wc -l) | |
src_loc=$(find $src_dir -type f -name '*.java' -exec cat {} \; | sed '/^\s*$/d' | wc -l) | |
test_files=$(find $test_dir -type f -name '*.java' | wc -l) | |
test_loc=$(find $test_dir -type f -name '*.java' -exec cat {} \; | sed '/^\s*$/d' | wc -l) | |
tests=$(find $test_dir -type f -name '*.java' -exec cat {} \; | grep @Test | wc -l) | |
echo "$commit;$src_files;$test_files;$src_loc;$test_loc;$tests" >> $dest_file | |
done | |
printf "\nDone.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment