可以说以下是我的 TFS 结构:
- 分支(文件夹)
- 模块 1(文件夹)
- Branch1(带有父 Dev 的分支)
- Branch2(带有父 Branch1 的分支)
- Branch3(带有父 Branch1 的分支)
- 模块 1(文件夹)
- 开发(分公司)
在代码中,我可以访问我的本地工作区以及一个VersionControlServer
对象。
我想要一个string GetParentPath(string path)
像下面这样的方法:
GetParentPath("$/Branches/Module1/Branch1"); // $/Dev
GetParentPath("$/Branches/Module1/Branch2"); // $/Branches/Module1/Branch1
GetParentPath("$/Branches/Module1/Branch3"); // $/Branches/Module1/Branch1
GetParentPath("$/Dev"); // throws an exception since there is no parent
我目前有以下内容,认为它有效,但它没有(老实说我也不希望它有效)
private string GetParentPath(string path)
{
return versionControlServer.QueryMergeRelationships(path)?.LastOrDefault()?.Item;
}