Project

General

Profile

bug #8105

better hotfix branch stragey in git flow to avoid commits in master which are missing in develop

Added by Andreas Kohlbecker about 1 month ago. Updated 10 days ago.

Status:
In Progress
Priority:
Priority14
Category:
devOps
Target version:
Start date:
02/18/2019
Due date:
% Done:

60%

Severity:
major
Found in Version:

Description

During the release of the taxeditor 5.5.0 it turned out, that the masterbranch has received commits from the hotfix/* barnch, which are not yet in den develop`:

In this commit the file eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/ChecklistEditorE4.java has been deleted.

This situation finally lead to a conflict when merging the release branch to master.

The git flow scheme clearly recommends merging all changes made to a hotfix branch back to develop. But this can not be done automatically since merge conflicts can are to be expected in this step with high propability.

A good strategy could be to verify just before finalizing the hotfix branch that all changes in the hotfix/* branch have been incorporated into develop. The git command cherry can be used to find commits that have been missed out.

This is illustrated here by a simple example:

  • hotfix branch 5.5.1 created
  • adding commit to develop: c6191df
  • adding commit to hotfix/5.5.1 : 305c21a (changes same line)

: git cherry develop hotfix/5.5.1
+ 305c21a613ed152685555559f1bdda4eaaed236b

Shows that exactly one commit is missing in develop

After merging hotfix/5.5.1 into develop and resolving the conflicts git cherry does not report any missing cherries.

*And the case which caused the problem during the release:

in this case we need to focus only to the current hotfix branch and will also specifying the <limit> argument for the cherry command:

: git cherry 2c28be6 5cb02a2 92f149d1f
+ e663916103a3e688714d14546aa664cef7f011c6
+ 8f3316f456dcafad1b9105ce2323cce5f915fb1a
+ 5cb02a236f205fd9c7b0b31d3b77fc24c7f8d99d

Without the limit git cherry would have reported all commit that once have been missed to integrate into develop of which many are no linger relevant for the actual release.

In the above example I needed to use the commit hashes since I was examining a historic situation. At the time of finalizing the hotfix release the command would have been:

git cherry develop hotfix/5.4.3 master

The only problem that needs to be solved is that we need to ignore the first commit in the hotfix branch since this is the commit by which the project version has been bumped by jenkins.

The first commit in a branch created by the release pipeline in jenkins can be found by e.g.:

git log --pretty=format:"%h" --author=jenkins master..hotfix/5.5.1 | tail -n 1   

HOW to use the git-hfx-cherry-check.sh script

assuming you have checked out the svn repository https://dev.e-taxonomy.eu/svn/trunk/server-scripts at ~/opt/server-scripts you can use the script in the following way:

~/opt/server-scripts/jenkins-ci/git-hfx-cherry-check.sh <hotfix-branch>

picture794-1.png View (67.7 KB) Andreas Kohlbecker, 02/18/2019 12:22 PM

picture794-2.png View (133 KB) Andreas Kohlbecker, 02/18/2019 12:22 PM

picture205-1.png View (96 KB) Andreas Kohlbecker, 02/18/2019 12:40 PM


Related issues

Related to Edit - feature request #7110: taxeditor hotfix script gitflow-finish.sh must not merge back to develop by default New 12/05/2017

History

#1 Updated by Andreas Kohlbecker about 1 month ago

#2 Updated by Andreas Kohlbecker about 1 month ago

  • Description updated (diff)

#3 Updated by Andreas Kohlbecker about 1 month ago

  • Description updated (diff)

#4 Updated by Andreas Kohlbecker about 1 month ago

  • Description updated (diff)

#5 Updated by Andreas Kohlbecker about 1 month ago

  • Description updated (diff)

#6 Updated by Andreas Kohlbecker 28 days ago

  • % Done changed from 0 to 40

Script to check for cherries in the HFX Finish jobs created: https://dev.e-taxonomy.eu/svn/trunk/server-scripts/jenkins-ci/git-hfx-cherry-check.sh

#7 Updated by Andreas Kohlbecker 28 days ago

and ... using git-hfx-cherry-check.sh in gitflow-finish.sh and maven-gitflow-HOTFIX-finish.sh

#8 Updated by Andreas Kohlbecker 28 days ago

  • Status changed from New to Resolved
  • % Done changed from 40 to 50

by this the git-hfx-cherry-check should be executed for all HFX_FINISH jobs, in case of errors the job will FAIL since the script exist with error code (2)

#9 Updated by Andreas Kohlbecker 28 days ago

  • Description updated (diff)

note for developers added to the ticket description .....

#10 Updated by Andreas Kohlbecker 28 days ago

  • Description updated (diff)

#11 Updated by Andreas Kohlbecker 27 days ago

  • Status changed from Resolved to Closed
  • Target version deleted (Release 5.6)
  • % Done changed from 50 to 100

#12 Updated by Andreas Kohlbecker 24 days ago

  • Status changed from Closed to In Progress
  • Target version set to Release 5.6
  • % Done changed from 100 to 60

it turned out that it can happen that cherries need to be modified when picking them from hotfix to develop. This happens for example when the cherry being picked is causing a conflict. the git cherrycommand will no longer detect the cherries as identical. to circimvent problems stemming from this we discussed two optional strategies:

Ich denke es ist wichtig, dass wir diesen check der cherries haben, so werden wir auf mögliche Fehler aufmerksam aber wir sollten A) auch zulassen, dass bestimmte commits ignoriert werden können.

B) Alternativ sollten wir uns aber über ein anderes Branchingmodel für die Hotfixes Gedanken machen. Vielleicht so:

  • hotfix branches werden nicht nach master gemerged, aber wir behalten den cherry-check bei, dieser führt aber nicht zum einem FAILED des jobs sondern es gibt lediglich einen Report über cherries die nicht nach develop integriert wurden.
  • Als Entwickler muss man sich diesen Report ansehen und entscheiden ob diese Commits für develop relevant sind oder nicht.

Nachlesen über die Hotfix-Problematik bei git flow sollten wir auch um zusehen ob andere das selbe Problem haben oder hatten, und zu welchen Lösungen die gekommen sind.

#13 Updated by Andreas Kohlbecker 17 days ago

  • Priority changed from New to Priority14

#14 Updated by Andreas Kohlbecker 10 days ago

  • Related to feature request #7110: taxeditor hotfix script gitflow-finish.sh must not merge back to develop by default added

#15 Updated by Andreas Kohlbecker 10 days ago

  • Description updated (diff)

I did a brief research on the topic of hotfix branches:

  1. git flow has the concept of support branches by which hot fix releases for earlier versions can be maintained (see second link below for details)
  2. also interesting is that you can allow for multiple hotfix branches at the same time with Git Flow: git config --add gitflow.multi-hotfix true

for further reading on these topics you may whant to follow these links

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)