I've got multiple SVN repositories of different projects which I would like to search for the same search term / regex, but without checking out or updating each project and doing the search manually on each of them.
I'd like to know if it is possible to search the file contents in multiple SVN repositories for some search term (or regex).
svn list --depth infinity <your-repo-here> to get a list of files in the repo, and then svn cat to get contents. You can add --xml key to list command to make parsing a bit simpler. Remember to use grep if you want to see 1 file, especially if you have thousands of files in the repository like the OP.
svn list is most useful if you want to see what files a repository has without downloading a working copy: $ svn list http://svn.red-bean.com/repos/test/support README. txt INSTALL examples/ … For further details, see the earlier section the section called “Listing versioned directories”.
You can either store your repositories locally and access them using the file:// protocol or you can place them on a server and access them with the http:// or svn:// protocols. The two server protocols can also be encrypted. You use https:// or svn+ssh:// , or you can use svn:// with SASL.
Here is a script:
if [[ $# < 2 ]]; then
echo "Usage: $0 REGEX TARGET..."
echo "where REGEX is a regular expression for grep"
echo "and TARGET... is a list of SVN repositories"
exit
fi
regex=$1
shift
for svnroot in $@; do
for path in $(svn ls --recursive $svnroot); do
if [[ $path != */ ]]; then
svn cat $svnroot/$path \
| grep --label="$svnroot/$path" --with-filename $regex
fi
done
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With