使用 Visual Studio 在线/TFS 2015 Api 创建 TFS 源分支

Create TFS Source Branch using Visual Studio Online / TFS 2015 Api

有谁知道如何使用 VSO 创建分支 Api。 Branches 的文档不包含 "create".

我一直在尝试通过 ChangeSet Api 来做,但没有成功。

这是 TFVC,不是 Git。

正如您在 "Branches" 页面中看到的那样,没有任何方法可以使用 Rest API 创建分支。大多数情况下,您现在只能 read/get 使用版本控制 API 的信息。

我建议您使用 Client Object Model Reference if you want to manage the Version Control programmatically. To create a branch, use the "CreateBranch()" method in Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer class.

REST API 显然允许创建分支。 令人困惑的是,人们认为这将是某种 the Branches endpoint 上的 PUT 操作。 不是。

在 REST API 中,分支只是作为变更集的一部分签入的另一种变更。

我自己花了很长时间才发现这一点;我在使用旧的 SOAP API 时相信,这不是 REST API 的一部分,从我在 WWW 上的 Q&As 中找到的内容来看,其他人都同意。 当然,使用 SOAP API 禁止使用 .NET 5,因为程序集仅适用于 .NET Framework。 放弃软件运行时上的放弃软件 API 并不是与源代码控制对话的令人满意的方式。 ☺

糟糕 Azure DevOps 文档对此 没有任何线索,除了 1 个晦涩的甚至不完整的句子隐藏在未成年人class:"List of merge sources in case of rename or branch creation." 唯一的其他线索是 JSON 中出现的内容,来自 get changeset changes,它描述了已创建分支的变更集。 (也已放弃)Azure DevOps sample code 甚至不包含删除项目的示例,更不用说分支了。

变更集通过 the changeset creation endpoint 签入。 单个更改是更改集更改列表中的 TfvcChange,其中:

  • 版本控制类型(这是一组标志)包含the branch flag;和
  • 更改的 merge source 指定源项和更改集编号的范围。

分支整个树似乎是分支目录 目录中的所有文件和目录的问题。

在 C♯ 或 PowerShell 中,这是 TfvcChange with a VersionControlChangeType of Branch, in a TfvcChangeset passed to TfvcHttpClientBase.CreateChangesetAsync()