I'm trying to get all branches of repository by using SharpSvn but I can not find any method can do it.
Is it possible to get all branches by using SharpSvn?
I'm trying to get all branches of repository by using SharpSvn but I can not find any method can do it.
Is it possible to get all branches by using SharpSvn?
I think Matt Z was on the right track, but that code doesn't compile. Here is an adjusted version that should work with the latest version of SharpSVN (as of Dec 2015).
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;
}
I don't know anything about SharpSVN, but branches in Subversion are just directory trees -- there's nothing special about them.
If your repository follows they typical layout with three top-level directories (trunk/ branches/ tags/), you can just check out the /branches directory to get all the branches side-by-side.
The SharpSvn.SvnClient class has a GetList() function that works really well:
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);
}
}
}
Once you have the collection, you can get the path of each item at the location. You can also use the Entry object to get information concerning each item, including whether it is a directory or a file, when it was last modified, etc.
© 2022 - 2024 — McMap. All rights reserved.