Is there an SVN crawler, that can walk thru an SVN repo and spitt out all existi开发者_C百科ng branches, or tags?
Preferably in Perl or Python ...
SVN tags and branches are just directories, usually following a particular naming convention. You can easily get them in perl like:
my @branches = `svn ls YourRepoBaseURL/branches`;
chomp @branches; # remove newlines
chop @branches; # remove trailing /
my @tags = `svn ls YourRepoBaseURL/tags`;
chomp @tags;
chop @tags;
Here is a little snippet to print information about files in a SVN repository in python:
# svncrawler.py
import os
import sys
import pysvn
svn_client = pysvn.Client()
for file_status in svn_client.status(sys.argv[1]):
print u'SVN File %s %s' % (file_status, file_status.text_status)
Call it like this:
python svncrawler.py my_repository
It should be easy to modify it to just print the tags and branches.
Thanks for all the help, here is what I came up with in python with your help:
# -*- coding: utf-8 -*-
import os
import sys
import pysvn
svnclient = pysvn.Client()
projects = svnclient.list(sys.argv[1])
for project_path, project_info in projects:
try:
project_branches = svnclient.list(project_path.path + '/branches/')
if ( len(project_branches)>2 ):
for branch, info in project_branches:
print branch.path
except:
pass
精彩评论