Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search the file contents in multiple subversion repositories?

Tags:

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).

like image 444
MicSim Avatar asked Mar 08 '10 09:03

MicSim


People also ask

How do I find a file in svn repository?

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.

How do I list all svn repositories?

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”.

How do I access my Tortoisesvn repository?

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.


1 Answers

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
like image 95
Brett Daniel Avatar answered Sep 28 '22 17:09

Brett Daniel