簡體   English   中英

如何使用SharpSvn獲取存儲庫的所有分支?

[英]How to get all branches of repository with SharpSvn?

我試圖通過使用SharpSvn獲取存儲庫的所有分支,但我找不到任何方法可以做到這一點。

是否可以通過使用SharpSvn獲得所有分支?

我認為Matt Z在正確的軌道上,但該代碼無法編譯。 這是一個調整版本,應該與最新版本的SharpSVN一起使用(截至2015年12月)。

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;
}

我對SharpSVN一無所知,但Subversion中的分支只是目錄樹 - 它們並沒有什么特別之處。

如果您的存儲庫遵循它們具有三個頂級目錄(trunk / branches / tags /)的典型布局,您可以檢查/ branches目錄以並排獲取所有分支。

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對象獲取有關每個項目的信息,包括它是目錄還是文件,上次修改時間等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM