Closed marcelopaulon closed 1 year ago
@marcelopaulon Cannot reproduce. Updating develop back to pre-merge state changes only pom.xml, how it could affect git submodule?
Can you include exact commands that you execute, step by step?
@aleksandr-m The problem happens because of git quirk when dealing with submodules. Performing a git checkout
to a different branch, where a submodule points to a distinct commit hash than the original branch leaves the working copy in a dirty state. In such a way that a subsequent git commit -a
may commit an unintended change to the submodule reference. The solution is to perform a git submodule update
before the commit.
This problem occurs when you update the xmls and perform a git commit -a
to update develop/release back to pre-merge stage. This can be partially mitigated using git config submodule.recurse true
, but the problem persists in the case of hotfixes, because submodule.recurse
does not work with git merge
(that has the same behavior).
1.19.0
is released.
The plugin looks for the .gitmodules
file and if it exists the git submodule update
command will be executed before each Git commit. This is needed to avoid leaving working copy in dirty state which can happen when switching between branches.
To explicitly control whether Git submodules will be updated before commit the updateGitSubmodules
parameter can be used. Setting it to true
will enable Git submodules update and false
will disable it even if .gitmodules
file exists. The default value is not set, meaning the plugin tries to automatically determine if update is needed.
Thank you! 💜
To reproduce the problem:
Expected behavior: both main and develop point to the latest commit in Asub.
Actual behavior: main points to the latest commit but develop does not (gitflow plugin's "Update develop version back to pre-merge state" commit overwrote the reference back to what it was in the develop branch before closing the release branch.
This seems to happen because the plugin is not performing
git submodule update
after checkout, and when it commits it uses the-a
option which adds all changes (including the dirty submodule reference, which points to the old commit in Asub).So, I've opened a PR to add the option of always performing a git submodule update before the plugin commits any changes.