Created
July 8, 2014 07:47
-
-
Save matteomattei/fd88741809a50f0d6886 to your computer and use it in GitHub Desktop.
How to calculate the number of inserted, deleted and modified lines in Subversion
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 | |
FIRST_REV=${1} | |
LAST_REV=${2} | |
REPO_ROOT=${3} | |
if [ -z "${FIRST_REV}" ] || [ -z "${LAST_REV}" ] || [ -z "${REPO_ROOT}" ] | |
then | |
echo "usage: ${0} first_revision last_revision repository_root" | |
exit 1 | |
fi | |
STAT=$(svn diff -r${FIRST_REV}:${LAST_REV} ${REPO_ROOT} 2> /dev/null | diffstat -m -t) | |
INS=0 | |
DEL=0 | |
MOD=0 | |
for f in ${STAT} | |
do | |
ins=$(echo ${f} | awk -F',' '{print $1}') | |
del=$(echo ${f} | awk -F',' '{print $2}') | |
mod=$(echo ${f} | awk -F',' '{print $3}') | |
INS=$((${INS}+${ins})) | |
DEL=$((${DEL}+${del})) | |
MOD=$((${MOD}+${mod})) | |
done | |
echo "INSERTED=${INS}" | |
echo "DELETE=${DEL}" | |
echo "MODIFIED=${MOD}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment