简体   繁体   English

来自特定分支的TFS条件拉取请求

[英]TFS Condition pull request from specific branch

There is any way to condition a pull request to come from an specific branch on Team Foundation Server 2017 ? 有什么方法可以调整来自Team Foundation Server 2017上特定分支的拉取请求? We are implementing gitflow and we would like to enforce pull requests to master always come from develop or hotfix branches . 我们正在实现gitflow ,我们希望强制执行对master的pull请求总是来自开发或修补程序分支。

I'm not sure it is possible to configure this with out-of-the-box features of TFS/VSTS. 我不确定是否可以使用TFS / VSTS的开箱即用功能进行配置。 Default branching policies (as @Andy mentioned in this answer ) can help you protect the target branches - those the pull requests address as To branch, but the From (source) branch can be any, and it is not enforced. 默认的分支策略(如本答案中提到的@Andy)可以帮助您保护目标分支 - 拉请求的地址为To分支,但From (源)分支可以是任何分支,并且不会强制执行。

If you are ready to write some code to support this scenario, here is the proposed approach: 如果您准备编写一些代码来支持这种情况,那么这是建议的方法:

Configure TFS/VSTS to run Azure Functions as a branching policy . 配置TFS / VSTS以将Azure Functions作为分支策略运行 Your function can be as simple as checking the source branch and set the pull request status to Failure in case the branch is not in the list of expected source branches. 您的功能可以像检查源分支一样简单,并将分支请求状态设置为Failure ,以防分支不在预期的源分支列表中。 Otherwise, set the PR status to Success . 否则,将PR状态设置为Success

One more useful link: Configure a branch policy for an external service . 另一个有用的链接: 为外部服务配置分支策略 You can configure it as a required policy, thus it won't be possible to complete the PR until it is satisfied. 您可以将其配置为必需的策略,因此在满足之前无法完成PR。

You can access a feature called Branch Policies to enforce pull requests from the specific branches. 您可以访问名为“ 分支策略”的功能,以强制执行来自特定分支的拉取请求。

After you set up a branch policy, you cannot directly push changes to the branch. 设置分支策略后,无法直接将更改推送到分支。 Changes to the branch are only made through pull requests. 只有拉取请求才能对分支进行更改。

In you scenario you just need to Configure branch policies for develop and hotfix branches. 在您的场景中,您只需要为develophotfix分支配置分支策略

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM