You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2018/05/04 22:12:46 UTC
[maven-scm] 01/01: [SCM-797] gitexe checkIn() fails due to Windows
command line length limitation
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch SCM-797
in repository https://gitbox.apache.org/repos/asf/maven-scm.git
commit 6545613312f66be2f3155cab77ccc7d910e7d791
Author: Rado Murin <ra...@gmail.com>
AuthorDate: Mon Apr 13 09:34:57 2015 +0200
[SCM-797] gitexe checkIn() fails due to Windows command line length limitation
This workaround executes 'git add' on a per-file basis to avoid length limitation.
The git commit has to be a generic one
This closes #30, #41, #49
---
.../gitexe/command/checkin/GitCheckInCommand.java | 53 ++++++++++++++++------
1 file changed, 38 insertions(+), 15 deletions(-)
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/checkin/GitCheckInCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java
index e30aae0..d963da6 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommand.java
@@ -38,6 +38,7 @@ import org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand;
import org.apache.maven.scm.provider.git.gitexe.command.status.GitStatusCommand;
import org.apache.maven.scm.provider.git.gitexe.command.status.GitStatusConsumer;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
@@ -45,6 +46,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -66,7 +68,7 @@ public class GitCheckInCommand
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
- int exitCode;
+ int exitCode = -1;
File messageFile = FileUtils.createTempFile( "maven-scm-", ".commit", null );
try
@@ -86,27 +88,46 @@ public class GitCheckInCommand
// if specific fileSet is given, we have to git-add them first
// otherwise we will use 'git-commit -a' later
- Commandline clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(), fileSet.getFileList() );
+ Commandline clAdd = null;
- exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr, getLogger() );
+ //SCM-714: Workaround for the Windows terminal command limit
+ if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
+ {
+ for ( File file: fileSet.getFileList() )
+ {
+ clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(),
+ Collections.singletonList( file ) );
+ exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr, getLogger() );
+
+ if ( exitCode != 0 )
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(), fileSet.getFileList() );
+ exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr, getLogger() );
+ }
if ( exitCode != 0 )
{
- return new CheckInScmResult( clAdd.toString(), "The git-add command failed.", stderr.getOutput(),
- false );
+ return new CheckInScmResult( clAdd.toString(), "The git-add command failed.",
+ stderr.getOutput(), false );
}
}
-
+
// SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with
// relativeRepositoryPath
Commandline clRevparse = GitStatusCommand.createRevparseShowToplevelCommand( fileSet );
-
+
stdout = new CommandLineUtils.StringStreamConsumer();
stderr = new CommandLineUtils.StringStreamConsumer();
URI relativeRepositoryPath = null;
-
+
exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr, getLogger() );
if ( exitCode != 0 )
{
@@ -139,13 +160,15 @@ public class GitCheckInCommand
+ "track)" );
}
}
-
+
if ( statusConsumer.getChangedFiles().isEmpty() )
{
return new CheckInScmResult( null, statusConsumer.getChangedFiles() );
}
- Commandline clCommit = createCommitCommandLine( repository, fileSet, messageFile );
+ //SCM-714: Workaround for the Windows terminal command limit
+ Commandline clCommit = createCommitCommandLine( repository, new ScmFileSet( fileSet.getBasedir() ),
+ messageFile );
exitCode = GitCommandLineUtils.execute( clCommit, stdout, stderr, getLogger() );
if ( exitCode != 0 )
@@ -154,7 +177,7 @@ public class GitCheckInCommand
false );
}
- if ( repo.isPushChanges() )
+ if ( repo.isPushChanges() )
{
Commandline cl = createPushCommandLine( getLogger(), repository, fileSet, version );
@@ -163,7 +186,7 @@ public class GitCheckInCommand
{
return new CheckInScmResult( cl.toString(), "The git-push command failed.", stderr.getOutput(),
false );
- }
+ }
}
List<ScmFile> checkedInFiles = new ArrayList<ScmFile>( statusConsumer.getChangedFiles().size() );
@@ -218,14 +241,14 @@ public class GitCheckInCommand
Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( fileSet.getBasedir(), "push" );
String branch = GitBranchCommand.getCurrentBranch( logger, repository, fileSet );
-
+
if ( branch == null || branch.length() == 0 )
{
throw new ScmException( "Could not detect the current branch. Don't know where I should push to!" );
}
-
+
cl.createArg().setValue( repository.getPushUrl() );
-
+
cl.createArg().setValue( "refs/heads/" + branch + ":" + "refs/heads/" + branch );
return cl;
--
To stop receiving notification emails like this one, please contact
michaelo@apache.org.