Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goal hotfix-finish runs post hotfix goals on wrong branch #402

Open
fhenning opened this issue Feb 22, 2024 · 1 comment
Open

Goal hotfix-finish runs post hotfix goals on wrong branch #402

fhenning opened this issue Feb 22, 2024 · 1 comment

Comments

@fhenning
Copy link

The goal hotfix-finish runs the post hofix goals on the wrong branch, if the option skipReleaseMergeProdBranch is set to true.

After some digging around I noticed that in GitFlowHotFixFinishMojo on line 261 there is the check if (skipMergeProdBranch && (supportBranchName == null)), if both conditions are true then it switches to the production branch. However, on line 267 it checks if it should run the post hotfix goals, which is just below the mentioned check.

If my understanding is correct, the finish goals runs the post hotfix goals on the hotfix only if there is a support branch or if skipMergeProdBranch is false. I expected that the post goals would execute from:

  1. the support branch after merging, if there is a support branch
  2. or the production branch after merging, if the merge is not skipped
  3. or the hotfix branch, if the option skipMergeProdBranch is true.

I just want to check if my understanding is correct or that I'm missing something here, before I create a pull-request (the change is rather simple move switching to the production after running the post hotfix goals).

I ran into the problem after moving to your gitflow plugin from the Atlassian one (jgitflow), which is no longer maintained.

@fhenning
Copy link
Author

What I see happening in the build server log is following:

... <build server logs>...
17:32:33  + mvn -f pom.xml gitflow:hotfix-finish -DuseSnapshotInHotfix=true -DhotfixBranch=hotfix/build_17 -Dverbose=true -DskipTests -DargLine=-DskipTests -Deol=lf -DdevelopmentVersion=24.02.0-JDK17-SNAPSHOT -DreleaseVersion=24.01.2-JDK17 -DskipReleaseMergeProdBranch=true -DskipMergeProdBranch=true -DskipReleaseMergeDevBranch=true -DskipMergeDevBranch=true -DkeepBranch=true -DscmCommentSuffix=-DpostHotfixGoals="clean deploy site site:stage site:deploy" 
... <more build stuff> ....
17:32:34  [INFO] --- gitflow-maven-plugin:1.21.0:hotfix-finish (default-cli) @ master-pom ---
17:32:34  [INFO] Checking for uncommitted changes.
17:32:34  [INFO] Fetching remote from 'origin'.
17:32:35  "origin/hotfix/build_17"
17:32:35  [INFO] Comparing local branch 'hotfix/build_17' with remote 'origin/hotfix/build_17'.
17:32:35  0	0
17:32:35  [INFO] Fetching remote from 'origin'.
17:32:35  "origin/develop"
17:32:35  [INFO] Local branch 'develop' doesn't exist. Trying check it out from 'origin'.
17:32:35  [INFO] Creating a new branch 'develop' from 'origin/develop' and checking it out.
17:32:35  Branch 'develop' set up to track remote branch 'develop' from 'origin'.
17:32:35  [WARNING] Switched to a new branch 'develop'
17:32:35  
17:32:35  [INFO] Fetching remote from 'origin'.
17:32:35  "origin/master"
17:32:35  [INFO] Local branch 'master' doesn't exist. Trying check it out from 'origin'.
17:32:35  [INFO] Creating a new branch 'master' from 'origin/master' and checking it out.
17:32:35  Branch 'master' set up to track remote branch 'master' from 'origin'.
17:32:35  [WARNING] Switched to a new branch 'master'
17:32:35  
17:32:35  [INFO] Fetching remote from 'origin'.
17:32:35  [INFO] Checking out 'hotfix/build_17' branch.
17:32:35  [WARNING] Switched to branch 'hotfix/build_17'
17:32:35  
17:32:35  [INFO] Cleaning and testing the project.
... <normal build output> ....
17:32:36  [INFO] Updating version(s) to '2023.03.1-JDK17'.
... <version update> ...
17:32:38  
17:32:38  [INFO] Committing changes.
17:32:38  [hotfix/build_17 cfebc2e] Update for next development version
17:32:38   1 file changed, 1 insertion(+), 1 deletion(-)
17:32:38  [INFO] Creating 'master-pom-2023.03.1-JDK17' tag.
17:32:38  [INFO] Checking out 'master' branch.
17:32:38  Your branch is up to date with 'origin/master'.
17:32:38  [WARNING] Switched to branch 'master'
17:32:38  
17:32:38  [INFO] Running Maven goals: clean deploy site site:stage site:deploy
... <deploy> ...

The last section is executing from the master branch, which is unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant