You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/04 11:03:00 UTC

[jira] [Commented] (WAGON-498) ScmWagon should work in binary and shallow mode when possible

    [ https://issues.apache.org/jira/browse/WAGON-498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16500064#comment-16500064 ] 

ASF GitHub Bot commented on WAGON-498:
--------------------------------------

asfgit closed pull request #42: [WAGON-498] ScmWagon should work in binary mode when possible
URL: https://github.com/apache/maven-wagon/pull/42
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java b/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
index 8fbbdeff..ceca314b 100644
--- a/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
+++ b/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
 import org.apache.maven.scm.ScmBranch;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFile;
@@ -485,9 +487,9 @@ private String checkOut( ScmProvider scmProvider, ScmRepository scmRepository, S
                 repoUrl += "/" + target.replace( '\\', '/' );
             }
             scmRepository = getScmRepository( repoUrl );
+
             CheckOutScmResult ret =
-                scmProvider.checkOut( scmRepository, new ScmFileSet( new File( checkoutDirectory, "" ) ),
-                                      makeScmVersion(), false );
+                checkOut( scmProvider, scmRepository, new ScmFileSet( new File( checkoutDirectory, "" ) ) );
 
             checkScmResult( ret );
         }
@@ -551,7 +553,8 @@ private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File
 
         if ( scmFilePath.length() != 0 )
         {
-            AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
+            AddScmResult result =
+                scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ), mkBinaryFlag() );
 
             /*
              * TODO dirty fix to work around files with property svn:eol-style=native if a file has that property, first
@@ -560,7 +563,9 @@ private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File
              */
             if ( !result.isSuccess() )
             {
-                result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
+                result =
+                    scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ),
+                                     mkBinaryFlag() );
             }
 
             addedFiles = result.getAddedFiles().size();
@@ -584,6 +589,26 @@ private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File
         return addedFiles;
     }
 
+    private CheckOutScmResult checkOut( ScmProvider scmProvider, ScmRepository scmRepository, ScmFileSet fileSet )
+        throws ScmException
+    {
+        ScmVersion ver = makeScmVersion();
+        CommandParameters parameters = mkBinaryFlag();
+        // TODO: AbstractScmProvider 6f7dd0c ignores checkOut() parameter "version"
+        parameters.setScmVersion( CommandParameter.SCM_VERSION, ver );
+        parameters.setString( CommandParameter.RECURSIVE, Boolean.toString( false ) );
+        parameters.setString( CommandParameter.SHALLOW, Boolean.toString( true ) );
+
+        return scmProvider.checkOut( scmRepository, fileSet, ver, parameters );
+    }
+
+    private CommandParameters mkBinaryFlag() throws ScmException
+    {
+        CommandParameters parameters = new CommandParameters();
+        parameters.setString( CommandParameter.BINARY, Boolean.toString( true ) );
+        return parameters;
+    }
+
     /**
      * @return true
      */
@@ -681,7 +706,7 @@ public void get( String resourceName, File destination )
                 // TODO: this should be checking out a full hierarchy (requires the -d equiv)
                 basedir.mkdirs();
 
-                scmProvider.checkOut( scmRepository, new ScmFileSet( basedir ), makeScmVersion() );
+                checkOut( scmProvider, scmRepository, new ScmFileSet( basedir ) );
             }
 
             if ( !scmFile.exists() )


 

----------------------------------------------------------------
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


> ScmWagon should work in binary and shallow mode when possible
> -------------------------------------------------------------
>
>                 Key: WAGON-498
>                 URL: https://issues.apache.org/jira/browse/WAGON-498
>             Project: Maven Wagon
>          Issue Type: Bug
>          Components: wagon-scm
>    Affects Versions: 3.0.0, 3.1.0
>            Reporter: Ilya Basin
>            Assignee: Michael Osipov
>            Priority: Major
>             Fix For: 3.1.0
>
>
> See SCM-867
> By default, CVSNT will corrupt jars during `mvn deploy`. Vanilla CVS less likely, but still possible due to Keyword substitution. ScmWagon needs to perform checkout and add commands with the '-kb' flag (binary).
> For that we need to call the overloaded methods added recently in maven-scm 1.9.6.
> UPD: As it turns out, svn may also change files, if enable-auto-props is on. The test case "testWagon" which could reveal that is disabled by mistake: it runs only if supportsGetIfNewer(), but we don't call getIfNewer() there.
> To demonstrate the issue, edit your subversion config file:
> {code:java}
> [miscellany]
> enable-auto-props = yes
> [auto-props]
> test-resource = svn:eol-style=CRLF{code}
> This will not affect checkin, because the test file already has LF, but the auto property will be set and next time the file will be checked out with CRLF and #testWagon will fail.
> UPD2: for git should also set the shallow flag



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)