Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all SVN repository URLs from a folder in recursive mode

We are looking for a script that will traverse in recursive mode all subfolders and list all SVN repository URLs and the path where it was found.

It will be used on /home folder of a user.

like image 421
Pentium10 Avatar asked Nov 08 '11 13:11

Pentium10


People also ask

How do I find my svn repository URL?

Repository URL examples: Apache HTTP Server: https://svn.example.com/repos/MyRepo/MyProject/trunk. svnserve: svn://svn.example.com/repos/MyRepo/MyProject/branches/MyBranch. Direct access (Unix-style): file:///var/svn/repos/MyRepo/MyProject/tags/1.1.0.

How do I check svn repository?

Check out files from Subversion repository In the Get from Version Control dialog, click Add Repository Location and specify the repository URL. Click Check Out. In the dialog that opens, specify the destination directory where the local copy of the repository files will be created, and click OK.


1 Answers

Recursively find directories, and for each of them try to get the SVN info. If it is successfull, then don't descend into the directory and print the directory name.

find -type d -exec bash -c "svn info {} > /dev/null 2> /dev/null" \; -prune -print

This will list the directories.

If you want the repository info, you can add it in the middle of the find exec command.

find -type d -exec bash -c "svn info {} 2> /dev/null | grep URL" \; -prune -print

Edit:

I found much better results by only testing for the presence of an .svn subdirectory. Then, svn info is called once at the end and grepped for Path and URL. (Plus using -0 to prevent from spaces in filenames.)

find -type d -exec test -d "{}/.svn" \; -prune -print0 | xargs -0 svn info | grep -e '\(Path\|URL\)'
like image 110
Didier Trosset Avatar answered Oct 03 '22 01:10

Didier Trosset