maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cquoss commented on a change in pull request #88: SCM-917 add untag for svn
Date Sat, 09 Feb 2019 12:38:19 GMT
cquoss commented on a change in pull request #88: SCM-917 add untag for svn
URL: https://github.com/apache/maven-scm/pull/88#discussion_r255297533
 
 

 ##########
 File path: maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/untag/SvnUntagCommand.java
 ##########
 @@ -0,0 +1,151 @@
+package org.apache.maven.scm.provider.svn.svnexe.command.untag;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.command.untag.AbstractUntagCommand;
+import org.apache.maven.scm.command.untag.UntagScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.svn.SvnCommandUtils;
+import org.apache.maven.scm.provider.svn.SvnTagBranchUtils;
+import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
+import org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.Os;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * SCM-917 provide untag
+ *
+ * scm:untag for provider svn is done by removing the tag dir
+ *
+ * @author Clemens Quoss
+ */
+public class SvnUntagCommand extends AbstractUntagCommand implements SvnCommand
+{
+
+    /** {@inheritDoc} */
+    @Override
+    public ScmResult executeUntagCommand( ScmProviderRepository repo, ScmFileSet fileSet,
String tag, String message )
+        throws ScmException
+    {
+        if ( tag == null || tag.trim().isEmpty() )
+        {
+            throw new ScmException( "tag name must be specified" );
+        }
+
+        SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
+
+        File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null );
+
+        try
+        {
+            FileUtils.fileWrite( messageFile.getAbsolutePath(), "UTF-8", message );
+        }
+        catch ( IOException ex )
+        {
+            return new UntagScmResult( null, "Error while making a temporary file for the
commit message: "
+                + ex.getMessage(), null, false );
+        }
+
+        Commandline cl = createCommandline( repository, fileSet, tag, messageFile );
+
+        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+
+        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+
+        if ( getLogger().isInfoEnabled() )
+        {
+            getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) );
+
+            if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
+            {
+                getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath()
);
+            }
+        }
+
+        int exitCode;
+
+        try
+        {
+            exitCode = SvnCommandLineUtils.execute( cl, stdout, stderr, getLogger() );
+        }
+        catch ( CommandLineException ex )
+        {
+            throw new ScmException( "Error while executing svn untag command.", ex );
+        }
+        finally
+        {
+            try
+            {
+                FileUtils.forceDelete( messageFile );
+            }
+            catch ( IOException ex )
+            {
+                // ignore
+            }
+        }
+
+        if ( exitCode == 0 )
+        {
+            return new UntagScmResult( cl.toString(), stdout.getOutput(), stderr.getOutput(),
true );
+        }
+        else
+        {
+            return new UntagScmResult( cl.toString(), stdout.getOutput(), stderr.getOutput(),
false );
 
 Review comment:
   Will change this, but shouldn't SvnTagCommand then also state "The svn copy command failed"
instead of "The svn tag command failed"?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message