You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/08/17 11:30:05 UTC

(maven-scm) branch master updated: Combine variable initialization and declaration (#1305)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scm.git


The following commit(s) were added to refs/heads/master by this push:
     new 79c2cc593 Combine variable initialization and declaration (#1305)
79c2cc593 is described below

commit 79c2cc593d8e6d5b111a2f1cc284d8e2d010cc72
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Sun Aug 17 11:30:01 2025 +0000

    Combine variable initialization and declaration (#1305)
---
 .../scm/plugin/CheckLocalModificationsMojo.java    | 24 ++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java
index 1e22fac0d..09bf2be6a 100644
--- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java
+++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckLocalModificationsMojo.java
@@ -66,23 +66,21 @@ public void execute() throws MojoExecutionException {
         }
         super.execute();
 
-        StatusScmResult result = null;
-
         try {
             ScmRepository repository = getScmRepository();
-            result = getScmManager().status(repository, getFileSet());
-        } catch (IOException | ScmException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        }
+            StatusScmResult result = getScmManager().status(repository, getFileSet());
 
-        if (!result.isSuccess()) {
-            throw new MojoExecutionException(
-                    "Unable to check for local modifications : " + result.getProviderMessage());
-        }
+            if (!result.isSuccess()) {
+                throw new MojoExecutionException(
+                        "Unable to check for local modifications : " + result.getProviderMessage());
+            }
 
-        if (!result.getChangedFiles().isEmpty()) {
-            getLog().error(errorMessage);
-            throw new MojoExecutionException(errorMessage);
+            if (!result.getChangedFiles().isEmpty()) {
+                getLog().error(errorMessage);
+                throw new MojoExecutionException(errorMessage);
+            }
+        } catch (IOException | ScmException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
         }
     }
 }