I'm looking for a way to search a whole subversion server.
I already got a piece of the puzzle to search within a repository. Now I need to do this for every repository.
I have to access this list from some unix shell script (perl, bash, etc.)
I was also looking to list repositories in SVN. I did something like this on shell prompt:
~$ svn list https://www.repo.rr.com/svn/main/team/gaurav
If you enable svn via apache and a SVNParentPath directive, you can add a SVNListParentPath On directive to your svn location to get a list of all repositories.
Your apache conf should look similar to this:
# optional auth stuff
SVNListParentPath On # <--- Add this line to enable listing of all repos
Sometimes you may wish to check on the timestamp for when the repo was updated, for getting this handy info you can use the svn -v (verbose) option as in
svn list -v svn://184.108.40.206/svn/repo/path
Doesn't your access to SVN work just like a Web service? When I access the top directory of my SVN server, I get a page that's essentially a Table Of Contents of the whole works. It's an Unordered List that I can simply scan through.
EDIT: Here's how I would do it from the command line:
wget http://user:[email protected]/ -O - | grep \<li\>
If you know your way around Java, you can use SvnKit to do browse, search and God knows what with your Subversion server.
After that, you can package your program and invoke it either via an Ant task or a shell script.
It's quite a "brute force" solution, but once you master SvnKit, you can really do lots of cool things.
You can run
svn log --search ARG --search-and ARG if you use Subversion 1.8 (or newer) command-line client. This allows you to search the repository history by
- revision's author,
- commit date,
- commit's log message text,
- list of changed paths.
It does not search by code itself, however it's still handy for simple repository search.
See SVNBook 1.8 |
svn log command-line reference.
If your server is Apache, you should be able to configure it to see the repository list with viewvc - this is the most basic one, other more complex interfaces exist but this is not your purpose here.
In some versions, ViewVC is an option of the standard installation now, for instance from Collabnet.
Edit: Nevermind my previous idea just above, Peter has a much simpler way of sending the repository list.
From there, you will have to:
- get the HTML page,
- extract the list, and
- process it for the individual repository search.
Unfortunately in this case I cannot think of something more straightforward.
There are examples on SO on how to extract text from HTML pages in Python, this would be a good option since Python also has bindings for SVN, to perform the repository search - you can still call
svn directly from Python if you prefer.
If Python is not your cup of tea, you will have to process that differently with GNU tools (wget, then parsing tools or existing packages - I can't be of much help there, Carl gave you some more details in this post).
At my company they didn't configure the server to provide a list of repositories, so
svn list worked for a specific repository but not at a higher level to list all repositories.
However they installed FishEye which gives you a GUI listing the repositories https://www.atlassian.com/software/fisheye
It's a paid option, so it's not for everyone, but the functionality is nice.