如何检索在两次git commit之间更改的maven模块列表 [英] How to retrieve the list of maven module changed between two commits in git
问题描述
我有一个带有主模块和多个子模块的Maven项目.我想知道是否有一种简单的方法来检索两次提交之间更改的所有模块.
I got a maven project with a main module and multiple submodule. I would like to know if there is a simple way to retrieve all the modules changed between two commits.
推荐答案
问了将近3年后,它的价值是什么:
For what it worth, almost 3 years after the question:
我基于git diff的启发式设计,基于事实是行家文物是由惯例决定的.
I designed on a heuristic based on git diff, based on the fact that maven artifacts are ruled by convention.
- 使用
git diff --name-status <commit1> <commit2>
提取所有文件更改
- 排序,添加文件,更新文件和删除文件
- 根据这些信息,如果文件看起来像 a/b/src/main/...或 c/src/test ,则按照maven约定,会影响模块是 a/b 和 c .如果文件看起来像 d/e/pom.xml ,那就简单!该模块是 d/e .
- Extract all files changes with
git diff --name-status <commit1> <commit2>
- Sort out, added files, updated files and deleted files
- From these info, if the file looks like a/b/src/main/... or c/src/test, by maven convention, impacted modules are a/b and c. If the file looks like d/e/pom.xml, easy! the module is d/e.
当然,这不能处理诸如 a/b/c/README.md 之类的更改.是在a,a/b还是a/b/c中?
Of course, this cannot handle changes such as a/b/c/README.md. Is it in a, a/b or a/b/c ?
我使用这种启发式方法列出了要为CI构建重新编译的所有模块.如果使用上述算法无法对其中一个文件进行分类,则只需重建整个项目即可.
I use this heuristic to list all modules to recompile for CI builds. If one of the files could not be classified by the above algorithm, I just rebuild the whole project.
欢呼
这篇关于如何检索在两次git commit之间更改的maven模块列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!