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

michaelo 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 6c31363  [SCM-486] Support signed tags for Git
6c31363 is described below

commit 6c31363a807973b96a178c41dcc1c2c7d781e3bf
Author: Davide Angelocola <davide.angeloc...@gmail.com>
AuthorDate: Wed Aug 1 21:40:33 2018 +0200

    [SCM-486] Support signed tags for Git
    
    This closes #81
---
 .../main/java/org/apache/maven/scm/ScmTagParameters.java  | 13 +++++++++++++
 .../main/java/org/apache/maven/scm/plugin/TagMojo.java    |  9 +++++++++
 .../provider/git/gitexe/command/tag/GitTagCommand.java    | 11 +++++++++--
 .../git/gitexe/command/tag/GitTagCommandTest.java         | 15 +++++++++++----
 4 files changed, 42 insertions(+), 6 deletions(-)

diff --git 
a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java 
b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java
index 2db3d18..12cea80 100644
--- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java
+++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmTagParameters.java
@@ -36,12 +36,15 @@ public class ScmTagParameters
 
     private boolean pinExternals = false;
 
+    private boolean sign = false;
+
     private String scmRevision;
 
     public ScmTagParameters()
     {
         this.remoteTagging = false;
         this.pinExternals = false;
+        this.sign = false;
     }
 
     public ScmTagParameters( String message )
@@ -79,6 +82,16 @@ public class ScmTagParameters
         this.pinExternals = pinExternals;
     }
 
+    public boolean isSign()
+    {
+        return sign;
+    }
+
+    public void setSign( boolean sign )
+    {
+        this.sign = sign;
+    }
+
     public String getScmRevision()
     {
         return scmRevision;
diff --git 
a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java 
b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
index a040d68..d4e7c6a 100644
--- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
+++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/TagMojo.java
@@ -98,6 +98,14 @@ public class TagMojo
     @Parameter( property = "pinExternals", defaultValue = "false" )
     private boolean pinExternals;
 
+    /**
+     * Enable the "--sign" in Git
+     *
+     * @since 1.10.1
+     */
+    @Parameter( property = "sign", defaultValue = "false" )
+    private boolean sign;
+
     /** {@inheritDoc} */
     public void execute()
         throws MojoExecutionException
@@ -145,6 +153,7 @@ public class TagMojo
             ScmTagParameters scmTagParameters = new ScmTagParameters( message 
);
             scmTagParameters.setRemoteTagging( remoteTagging );
             scmTagParameters.setPinExternals( pinExternals );
+            scmTagParameters.setSign( sign );
 
             TagScmResult result = provider.tag( repository, getFileSet(), 
finalTag, scmTagParameters );
 
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java
index f5b12eb..068ec3e 100644
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java
+++ 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommand.java
@@ -92,7 +92,9 @@ public class GitTagCommand
 
             int exitCode;
 
-            Commandline clTag = createCommandLine( repository, 
fileSet.getBasedir(), tag, messageFile );
+            boolean sign = scmTagParameters.isSign();
+
+            Commandline clTag = createCommandLine( repository, 
fileSet.getBasedir(), tag, messageFile, sign );
 
             exitCode = GitCommandLineUtils.execute( clTag, stdout, stderr, 
getLogger() );
             if ( exitCode != 0 )
@@ -147,10 +149,15 @@ public class GitTagCommand
     // ----------------------------------------------------------------------
 
     public static Commandline createCommandLine( GitScmProviderRepository 
repository, File workingDirectory,
-                                                 String tag, File messageFile )
+                                                 String tag, File messageFile, 
boolean sign )
     {
         Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( 
workingDirectory, "tag" );
 
+        if ( sign )
+        {
+            cl.createArg().setValue( "-s" );
+        }
+
         cl.createArg().setValue( "-F" );
         cl.createArg().setValue( messageFile.getAbsolutePath() );
 
diff --git 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java
 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java
index 68c4750..6633dc1 100644
--- 
a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java
+++ 
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/tag/GitTagCommandTest.java
@@ -55,21 +55,28 @@ public class GitTagCommandTest
     public void testCommandLineTag()
         throws Exception
     {
-        testCommandLine( "scm:git:http://foo.com/git/trunk";, "my-tag-1", "git 
tag " + messageFileString + " my-tag-1" );
+        testCommandLine( "scm:git:http://foo.com/git/trunk";, "my-tag-1", "git 
tag " + messageFileString + " my-tag-1", false );
     }
 
     public void testCommandLineWithUsernameAndTag()
         throws Exception
     {
         testCommandLine( "scm:git:http://anonym...@foo.com/git/trunk";, 
"my-tag-1",
-                         "git tag " + messageFileString + " my-tag-1" );
+                         "git tag " + messageFileString + " my-tag-1", false );
+    }
+
+    public void testCommandLineWithUsernameAndTagAndSign()
+            throws Exception
+    {
+         testCommandLine( "scm:git:http://anonym...@foo.com/git/trunk";, 
"my-tag-1",
+                          "git tag -s " + messageFileString + " my-tag-1", 
true );
     }
 
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-    private void testCommandLine( String scmUrl, String tag, String 
commandLine )
+    private void testCommandLine( String scmUrl, String tag, String 
commandLine, boolean sign )
         throws Exception
     {
         File workingDirectory = getTestFile( "target/git-checkin-command-test" 
);
@@ -78,7 +85,7 @@ public class GitTagCommandTest
 
         GitScmProviderRepository gitRepository = (GitScmProviderRepository) 
repository.getProviderRepository();
 
-        Commandline cl = GitTagCommand.createCommandLine( gitRepository, 
workingDirectory, tag, messageFile );
+        Commandline cl = GitTagCommand.createCommandLine( gitRepository, 
workingDirectory, tag, messageFile, sign );
 
         assertCommandLine( commandLine, workingDirectory, cl );
     }

Reply via email to