Project

General

Profile

Actions

bug #8105

open

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

Added by Andreas Kohlbecker about 5 years ago. Updated about 3 years ago.

Status:
In Progress
Priority:
Priority14
Category:
devOps
Target version:
Start date:
Due date:
% Done:

60%

Estimated time:
Severity:
major
Found in Version:
Tags:
git

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>

Files

picture794-1.png (67.7 KB) picture794-1.png Andreas Kohlbecker, 02/18/2019 12:22 PM
picture794-2.png (133 KB) picture794-2.png Andreas Kohlbecker, 02/18/2019 12:22 PM
picture205-1.png (96 KB) picture205-1.png 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 defaultNewAndreas Kohlbecker

Actions
Actions #1

Updated by Andreas Kohlbecker about 5 years ago

Actions #2

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)
Actions #3

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)
Actions #4

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)
Actions #5

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)
Actions #6

Updated by Andreas Kohlbecker about 5 years 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

Actions #7

Updated by Andreas Kohlbecker about 5 years ago

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

Actions #8

Updated by Andreas Kohlbecker about 5 years 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)

Actions #9

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)

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

Actions #10

Updated by Andreas Kohlbecker about 5 years ago

  • Description updated (diff)
Actions #11

Updated by Andreas Kohlbecker about 5 years ago

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

Updated by Andreas Kohlbecker about 5 years 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.

Actions #13

Updated by Andreas Kohlbecker about 5 years ago

  • Priority changed from New to Priority14
Actions #14

Updated by Andreas Kohlbecker about 5 years ago

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

Updated by Andreas Kohlbecker about 5 years 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

Actions #16

Updated by Andreas Kohlbecker about 5 years ago

  • Target version changed from Release 5.6 to Release 5.7
Actions #17

Updated by Andreas Müller almost 5 years ago

  • Target version changed from Release 5.7 to Release 5.8
Actions #18

Updated by Andreas Kohlbecker over 4 years ago

  • Target version changed from Release 5.8 to Release 5.10
Actions #19

Updated by Andreas Kohlbecker over 4 years ago

  • Target version changed from Release 5.10 to Release 5.11
Actions #20

Updated by Andreas Müller over 4 years ago

  • Target version changed from Release 5.11 to Release 5.12
Actions #21

Updated by Andreas Kohlbecker over 4 years ago

  • Target version changed from Release 5.12 to Release 5.13
Actions #22

Updated by Andreas Kohlbecker about 4 years ago

  • Target version changed from Release 5.13 to Release 5.15
Actions #23

Updated by Andreas Müller about 4 years ago

  • Subject changed from better hotfix branch stragey in git flow to avoid commits in master which are missing in develop to better hotfix branch strategy in git flow to avoid commits in master which are missing in develop
Actions #24

Updated by Andreas Kohlbecker almost 4 years ago

  • Target version changed from Release 5.15 to Release 5.18
Actions #25

Updated by Andreas Kohlbecker over 3 years ago

  • Target version changed from Release 5.18 to Release 5.19
Actions #26

Updated by Andreas Kohlbecker about 3 years ago

  • Target version changed from Release 5.19 to Release 5.21
Actions #27

Updated by Andreas Kohlbecker about 3 years ago

  • Tags set to git
Actions #28

Updated by Andreas Kohlbecker about 3 years ago

  • Target version changed from Release 5.21 to Release 5.22
Actions #29

Updated by Andreas Kohlbecker about 3 years ago

  • Target version changed from Release 5.22 to Release 5.45
Actions

Also available in: Atom PDF