如何在git feature branch工作流中处理xml / html? [英] How to handle xml/html in git feature branch workflow?

查看:164
本文介绍了如何在git feature branch工作流中处理xml / html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目在代码方面工作的时间相当接近(在代码的相当小的地理区域内并行发生了很多变化),而基于功能分支的git工作流对于我们的java代码非常有用。

但是xml / html的东西运行得不是很好。简单无关的更改(设计师添加了一个周边div,开发人员更改了其中一个元素的ID),这实际上是非常有害的合并。

我意识到如何处理这个问题可能有几个选项。一个好的git xml合并将是最佳的,或者限制xml / html代码的重新格式化。不在这种近距离工作会是另一个(不可接受的)选择。



你如何有效地解决这个问题?解决方案

Git允许对于自定义合并驱动程序,通过 gitattribute 选择每个路径(例如,为所有人 *。xml 文件)。

您需要查找的是一个支持XML的合并驱动程序,编写一个简单的脚本来转换Git约定和合并驱动程序约定。例如 XML :: Merge Perl模块。有 XyDiff ,但它看起来像缺少三路合并(和我猜测对于XML构建3-way差异合并,如正式对Diff3 论文的研究(PDF)将不起作用)。您还可以阅读匹配,区分和合并XML 博客文章(或其中引用的文章)。

另一个解决方案是针对XML文件合并属性像二进制文件合并冲突),并使用一些图形合并工具来解决合并冲突,可能通过 git mergetool


Our project is working within fairly close quarters code-wise (a lot of changes happening in parallel in a fairly small geographical area of the code), and our feature branch based git workflow works out really nice for our java code.

But the xml/html stuff is not working really well. Simple unrelated changes (a designer adding a surrounding div, a developer changing an id of an element within) gives really disasterous merges.

I realize there may be several options on how to handle this. A good git xml merge would be optimal, or putting restrictions on reformatting of xml/html code another. Not working in such close quarters would be another (unacceptable) option.

How do you solve this problem efficiently ?

解决方案

Git allows for custom merge drivers, selected via gitattributes per path (e.g. for all *.xml files).

What you need to find is a XML-aware merge driver, plus possibly also write a simple script to transform between Git conventions and said merge driver conventions. There is for example XML::Merge Perl module. There is XyDiff, but it looks like it lacks three-way merge (and I guess that for XML building 3-way merge from diffs like described in A Formal Investigation of Diff3 paper (PDF) wouldn't work). You can also read Matching, diffing and merging XML blog post (or article referenced therein).

Another solution would be to unset merge attribute for XML files (they would be treated like binary files wrt. merge conflicts), and use some graphical merge tool to resolve merge conflicts, perhaps via git mergetool.

这篇关于如何在git feature branch工作流中处理xml / html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆