You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2018/04/13 03:17:16 UTC
[GitHub] olamy closed pull request #69: [SCM-882] git checkout in binary
mode when requested
olamy closed pull request #69: [SCM-882] git checkout in binary mode when requested
URL: https://github.com/apache/maven-scm/pull/69
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/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java
index 296e51b27..d2e8613c7 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitCheckOutCommand.java
@@ -19,10 +19,15 @@
* under the License.
*/
+import java.io.File;
+
+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.ScmFileSet;
import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.ScmVersion;
import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
@@ -39,8 +44,6 @@
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
-import java.io.File;
-
/**
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
*
@@ -57,10 +60,15 @@
* TODO We currently assume a '.git' directory, so this does not work for --bare repos
* {@inheritDoc}
*/
- protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet,
- ScmVersion version, boolean recursive, boolean shallow )
+ @Override
+ public ScmResult executeCommand( ScmProviderRepository repo, ScmFileSet fileSet,
+ CommandParameters parameters )
throws ScmException
{
+ ScmVersion version = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
+ boolean binary = parameters.getBoolean( CommandParameter.BINARY, false );
+ boolean shallow = parameters.getBoolean( CommandParameter.SHALLOW, false );
+
GitScmProviderRepository repository = (GitScmProviderRepository) repo;
if ( GitScmProviderRepository.PROTOCOL_FILE.equals( repository.getFetchInfo().getProtocol() )
@@ -85,7 +93,7 @@ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo,
}
// no git repo seems to exist, let's clone the original repo
- Commandline clClone = createCloneCommand( repository, fileSet.getBasedir(), version, shallow );
+ Commandline clClone = createCloneCommand( repository, fileSet.getBasedir(), version, binary, shallow );
exitCode = GitCommandLineUtils.execute( clClone, stdout, stderr, getLogger() );
if ( exitCode != 0 )
@@ -163,10 +171,12 @@ public static Commandline createCommandLine( GitScmProviderRepository repository
* create a git-clone repository command
*/
private Commandline createCloneCommand( GitScmProviderRepository repository, File workingDirectory,
- ScmVersion version, boolean shallow )
+ ScmVersion version, boolean binary, boolean shallow )
{
Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory.getParentFile(), "clone" );
+ forceBinary( cl, binary );
+
if ( shallow )
{
cl.createArg().setValue( "--depth" );
@@ -189,6 +199,15 @@ private Commandline createCloneCommand( GitScmProviderRepository repository, Fil
return cl;
}
+ private void forceBinary( Commandline cl, boolean binary )
+ {
+ if ( binary )
+ {
+ cl.createArg().setValue( "-c" );
+ cl.createArg().setValue( "core.autocrlf=false" );
+ }
+ }
+
/**
* create a git-pull repository command
*/
@@ -228,4 +247,17 @@ private Commandline createPullCommand( GitScmProviderRepository repository, File
}
return cl;
}
+
+ /**
+ * The overriden {@link #executeCommand(ScmProviderRepository, ScmFileSet, CommandParameters)} in this class will
+ * not call this method!
+ * <p>
+ * {@inheritDoc}
+ */
+ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet,
+ ScmVersion version, boolean recursive, boolean shallow )
+ throws ScmException
+ {
+ throw new UnsupportedOperationException( "Should not get here" );
+ }
}
----------------------------------------------------------------
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