Skip to content

Instantly share code, notes, and snippets.

@matteomattei
Created July 8, 2014 07:47
Show Gist options
  • Save matteomattei/fd88741809a50f0d6886 to your computer and use it in GitHub Desktop.
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
#!/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