Managing Multi-Project Branches in Git

2019-05-10 16:07发布

Are there tools to achieve the following abstract operations in a Maven project/SCM scenario?

  • Given an application project, create branches for the application and all the snapshot libraries that it uses, transitively; these branches should be manageable as one logical branch (see next)
  • Given the logical branch of an application project, release it (by running Maven release); this means releasing multiple branches, one per library

Background (original):

As you know, Git recommends using the repository-per-project structuring paradigm. At the same time, any serious project, in our case Maven-based, is attached to several in-house libraries. During any sprint, both the project and the libraries that it is attached to are modified. In a Git world, this means that modifications will exist across several Git repositories.

If we wanted to branch out the work in the sprint, perhaps because we use Gitflow, which invites that we create a release branch at the end of our sprint, how would we do it in a logical manner across all the libraries involved in the sprint, instead of manually branching each library?

A Maven-aware tool (one that can introspect the POMs to figure out the transitive snapshot dependency list) will be even better.

Can I create a logical relationship between my multiple physical branches (one per project) that represent my one logical branch?

Does Git, or some Git tool, support logical branches?

I'm hoping you're not going to say submodules. What I'm looking for here is to abstract out the details of the VCS, not to become a Git guru. Also, I'm looking to do things in one operation where possible, as having to individually branch each library is error prone and easily forgotten.

2条回答
仙女界的扛把子
2楼-- · 2019-05-10 17:00

Look what I found looking for something else about Gitflow: https://github.com/nvie/gitflow

It doesn't work with Maven, so it doesn't fit my needs, but maybe it helps you.

查看更多
爷的心禁止访问
3楼-- · 2019-05-10 17:07

Setup a Jenkins server.

It can build each maven module as a separate project and then automatically rebuild any other projects that has a snapshot dependency relationship.

Update

The GIT plugin for Jenkins has a feature for managing the automatic merging of development feature branches into a "master" or "integration" branch. See the documentation:

https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-AdvancedFeatures

Another option is to control feature development using a code review tool like Gerrit. Again it's Gerrit that controls changes integrated onto the shared code stream and Gerrit can be integrated with Jenkins to ensuring all submitted change-sets pass the code tests.

Finally releases are cut using the M2 Release plugin, which is a wrapper around the standard release plugin. (Means you'll always have two types of build in Jenkins. Automated builds triggered by code commits and release builds explicitly triggered via the UI).

查看更多
登录 后发表回答