简体   繁体   English

自动工具检查分支是否在git中发生冲突

[英]automated tool to check branches for conflicts in git

We using feature branches and I'm looking for a tool that monitors branches for conflicts? 我们使用功能分支,我正在寻找一种监视分支冲突的工具? I know this is a reason for us to be use main-based development with feature switches, but that not an option in the short term. 我知道这是我们将基于主体的开发与功能开关一起使用的原因,但是短期内这不是一个选择。

The situation is we have a DEV branch and two feature branches (A and B) which have some overlap and are modifying the same systems/files. 情况是我们有一个DEV分支和两个要素分支(A和B),它们有一些重叠并正在修改相同的系统/文件。

The current flow is: we merge A into DEV, then merge DEV into B, deal with conflicts, then merge B into DEV. 当前流程是:我们将A合并为DEV,然后将DEV合并为B,处理冲突,然后将B合并为DEV。

We're trying to minimize the conflicts that are happening between A and B. Often the features are unrelated and there are not conflicts. 我们正在尝试使A和B之间发生的冲突最小化。通常这些功能是不相关的,没有冲突。 But when there are (modifying the same lines) or potential merge problems (eg, both touching the same file) I would like to have some report to alert us about it to make sure that Team A and Team B work more closely together to minimize or avoid the conflicts. 但是,当存在(修改相同的行)或潜在的合并问题(例如,都触摸同一个文件)时,我希望有一些报告来提醒我们有关此问题,以确保A团队和B团队更紧密地合作以最大程度地减少或避免冲突。

Does anyone know of a tool or process to effectively deal with this? 有人知道有效地解决此问题的工具或过程吗?

There is a tool that do just what you want: it parses git diff output and searches for conflicts between branches (generally speaking, between treeishes). 有一个工具可以满足您的需求:它分析git diff输出并搜索分支之间的冲突(通常来说,在树状结构之间)。

It is written in python3 and can be obtained from PYPI: pip3 install gitconflict . 它是用python3编写的,可以从PYPI获得: pip3 install gitconflict

Usage: 用法:

git conflict A B DEV

Prints first found conflict between given treeishes. 打印给定树状结构之间首先发现的冲突。 Returns 1 if no conflicts found, 0 otherwise. 如果没有发现冲突,则返回1,否则返回0。

Limitations: 局限性:

  • it doesn't detect binary file conflicts 它不会检测到二进制文件冲突
  • may produce false positives in some cases (tool warns you that there is a conflict but git will merge w/o conflict or auto-resolve it) 在某些情况下可能会产生误报(工具会警告您存在冲突,但是git将合并没有冲突或自动解决冲突)

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

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