强制git自定义合并驱动程序用于合并pom.xml(maven)文件 [英] Force git custom merge driver for the purpose of merging pom.xml (maven) files

查看:845
本文介绍了强制git自定义合并驱动程序用于合并pom.xml(maven)文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 pom.xml (Maven)文件配置了一个自定义git合并驱动程序。



配置:



.gitattributes 文件:

  pom.xml merge = pommerge 

.gitconfig file:

  [mergepommerge] 
name = Maven的pom.xml的自定义合并驱动程序
driver = mergepom.py%O%A%B

这对解决此冲突非常有用一种文件。不幸的是,这并不能解决 pom.xml 文件的所有问题或问题。当且仅当 pom.xml 在主分支(所以,我们称之为'git merge otherbranch'的分支)和我们想合并的分支('otherbranch')。



我们会像永远使用我们的合并驱动程序为pom文件,即使pom文件只在1分支中更改,并且可以合并而不会发生冲突。



有没有办法在这种情况下强制我们的定制'pommerge'驱动?

更新
我已经尝试过任何事情,但没有运气。我甚至检查出git源代码,并在代码中添加了更多的日志记录,并安装/ MAKE它检查我是否可以找出是否有某个特定的扩展点可以使用。
但是代码很难理解在哪些情况下遵循代码中的路径,所以这种努力产生了比解决方案更多的挫败感;)..

我可以使它工作的唯一方法,这不是一个解决方案,是在合并之前在两端(分支)更改文件。但这不是非常用户友好的



我仍然希望有人提出一个天才的解决方案或线索,这有助于我进一步了解这一挑战。



谢谢大家!

解决方案

您想要的是自定义合并策略,并且您已经定义了合并驱动器



仅在冲突时调用驱动程序,而在任何时候合并两个提交时都会使用策略。

请参阅这个答案为如何设置您的解决方案:

.com / a / 23140455/6084013

I've got a custom git merge driver configured for pom.xml (Maven) files.

The configuration:

The .gitattributes file:

pom.xml merge=pommerge

And the .gitconfig file:

[merge "pommerge"]
    name = A custom merge driver for Maven's pom.xml
    driver = mergepom.py %O %A %B

This works great for resolving conflicts in this kind of file. Unfortunately this doesn't solve all or problems for pom.xml files.. This driver is only called while merging if and only if the pom.xml is changed in both the main branch (so, the branch in which we call 'git merge otherbranch') and the branche we'd like to merge ('otherbranch').

We'd like to always use our merge driver for pom files, even if the pom file is only changed in 1 branch and can be be merged without conflicts.

Is there a way to force our custom 'pommerge' driver in this situation?

Update I've tried almost anything, but without luck. I even checkout out the git source code and added more logging to the code and installed/MAKE'd it to check if I could find out if there was a specific extension point I could use somehow. But the code is pretty hard to understand in which cases which path in the code is followed, so this effort produced more frustations than solutions;)..

The only way I can make it to work, which is not a solution, is to change the file at both ends (branches), before merging.. But this is not very user friendly

I still hope someone comes up with a genius solution or clue which helps me get a little bit further with this challenge.

Thanks you all for your time!

解决方案

What you want is a custom merge strategy, and you have defined a merge driver.

A driver is called only on conflicts, while a strategy is used anytime two commits are merged.

See this answer for how to set up your solution:

https://stackoverflow.com/a/23140455/6084013

这篇关于强制git自定义合并驱动程序用于合并pom.xml(maven)文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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