From e972a3c464f5c98ce30e67c746f7203a416993c1 Mon Sep 17 00:00:00 2001 From: Marcelo Paulon Date: Tue, 3 May 2022 16:00:53 -0300 Subject: [PATCH] Add update submodule before commit option --- README.md | 3 +++ pom.xml | 2 +- .../maven/plugin/gitflow/AbstractGitFlowMojo.java | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c185fe8f..70e332ca 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,9 @@ The `gitflow:release`, `gitflow:release-finish` and `gitflow:hotfix-finish` goal All goals have `gpgSignCommit` parameter. Set it to `true` to sign commits with configured personal key. The default value is `false`. +### Updating submodules before commit + +All goals have `updateSubmodulesBeforeCommit` parameter. Set it to `true` to run `git submodule update` before the plugin commits any changes. The default value is `true`. # Support for Reproducible Builds diff --git a/pom.xml b/pom.xml index d584fc4b..336c6727 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ gitflow-maven-plugin maven-plugin gitflow-maven-plugin - 1.18.1-SNAPSHOT + 1.19.0-SNAPSHOT The Git-Flow Maven Plugin supports various Git workflows, including Vincent Driessen's successful Git branching model and GitHub Flow. This plugin runs Git and Maven commands from the command line. Supports Eclipse Plugins build with Tycho. diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java index ec00b588..869f4269 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -143,6 +143,14 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo { @Parameter(property = "gpgSignCommit", defaultValue = "false") private boolean gpgSignCommit = false; + /** + * Whether to update submodules before commit. + * + * @since 1.19.0 + */ + @Parameter(property = "updateSubmodulesBeforeCommit", defaultValue = "true") + private boolean updateSubmodulesBeforeCommit = true; + /** * Whether to set -DgroupId='*' -DartifactId='*' when calling * versions-maven-plugin. @@ -796,6 +804,11 @@ protected void gitCommit(String message, Map messageProperties) message = replaceProperties(message, messageProperties); + if (updateSubmodulesBeforeCommit) { + getLog().info("Updating submodules before commit."); + executeGitCommand("submodule", "update"); + } + if (gpgSignCommit) { getLog().info("Committing changes. GPG-signed.");