C# 如何使用SharpSvn获取存储库的所有分支?
我试图使用SharpSvn获得存储库的所有分支,但我找不到任何方法可以做到这一点C# 如何使用SharpSvn获取存储库的所有分支?,c#,svn,sharpsvn,C#,Svn,Sharpsvn,我试图使用SharpSvn获得存储库的所有分支,但我找不到任何方法可以做到这一点 使用SharpSvn是否可以获得所有分支?我对SharpSvn一无所知,但Subversion中的分支只是目录树——它们没有什么特别之处 如果您的存储库遵循三个顶级目录trunk/branchs/tags/的典型布局,您只需签出/branchs目录即可并行获取所有分支。SharpSvn.SvnClient类有一个GetList函数,该函数运行得非常好: using (SvnClient svnClient = ne
使用SharpSvn是否可以获得所有分支?我对SharpSvn一无所知,但Subversion中的分支只是目录树——它们没有什么特别之处
如果您的存储库遵循三个顶级目录trunk/branchs/tags/的典型布局,您只需签出/branchs目录即可并行获取所有分支。SharpSvn.SvnClient类有一个GetList函数,该函数运行得非常好:
using (SvnClient svnClient = new SvnClient())
{
Collection contents;
List files = new List();
if (svnClient.GetList(new Uri(svnUrl), out contents))
{
foreach(SvnListEventArgs item in contents)
{
files.Add(item.Path);
}
}
}
拥有集合后,可以在该位置获取每个项目的路径。您还可以使用Entry对象来获取有关每个项目的信息,包括它是目录还是文件、上次修改的时间等。我认为Matt Z的思路是正确的,但代码无法编译。这是一个调整后的版本,应与截至2015年12月的最新版本的SharpSVN一起使用
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SharpSvn;
....
private List<string> GetSVNPaths()
{
List<string> files = new List<string>();
using (SvnClient svnClient = new SvnClient())
{
Collection<SvnListEventArgs> contents;
//you can get the url from the TortoiseSVN repo-browser if you aren't sure
if (svnClient.GetList(new Uri(@"https://your-repository-url/"), out contents))
{
files.AddRange(contents.Select(item => item.Path));
}
}
return files;
}