Skip to content

Instantly share code, notes, and snippets.

@tonio
Forked from ubermuda/gist:139517
Created July 2, 2009 17:57
Show Gist options
  • Save tonio/139613 to your computer and use it in GitHub Desktop.
Save tonio/139613 to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: ./svngrep http://svn.example.com/trunk/file foobar
#
# This example will look for the string foobar in all rev of file
#
# @todo better argv handling
# @todo add a --verbose option
# @todo automatic branches and tags detection (?)
SVN_URL=$1
NEEDLE=$2
REV_MIN=`svn log $SVN_URL --xml | grep revision | tail -1 | grep -Eo '[0-9]+'`
REV_MAX=`svn log $SVN_URL --xml | grep revision | head -1 | grep -Eo '[0-9]+'`
echo "checking revisions $REV_MIN to $REV_MAX..."
for REV in `seq $REV_MIN $REV_MAX`; do
RESULT=`svn cat -r $REV $SVN_URL | grep -n $NEEDLE`
if [ ! -z "$RESULT" ]; then
echo "found in rev $REV:"
echo $RESULT
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment