[SCM-791] GitExe Provider does not work properly in Cygwin
This closes #77
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/GitCommandLineUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java
index 4f23195..bb1dad1 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtils.java
@@ -19,6 +19,8 @@
* under the License.
*/
+import org.apache.commons.io.FilenameUtils;
+
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.log.ScmLogger;
import org.apache.maven.scm.provider.git.util.GitUtil;
@@ -34,7 +36,7 @@
/**
* Command line construction utility.
- *
+ *
* @author Brett Porter
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
*
@@ -73,7 +75,7 @@
}
// no setFile() since this screws up the working directory!
- cl.createArg().setValue( relativeFile );
+ cl.createArg().setValue( FilenameUtils.separatorsToUnix( relativeFile ) );
}
}
catch ( IOException ex )
@@ -84,7 +86,7 @@
}
/**
- *
+ *
* @param workingDirectory
* @param command
* @return
@@ -97,7 +99,7 @@
/**
* Creates a {@link Commandline} for which the toString() do not display
* password.
- *
+ *
* @param workingDirectory
* @param command
* @return CommandLine with anonymous output.
@@ -176,4 +178,4 @@
return exitCode;
}
-}
\ No newline at end of file
+}
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/changelog/GitChangeLogCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java
index fe62ef6..e4879ba 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommand.java
@@ -236,7 +236,7 @@
// We have to report only the changes of the current project.
// This is needed for child projects, otherwise we would get the changelog of the
// whole parent-project including all childs.
- cl.createArg().setFile( workingDirectory );
+ cl.createArg().setValue( "." );
return cl;
}
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 d2e8613..7fcda9c 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
@@ -194,7 +194,7 @@
cl.createArg().setValue( repository.getFetchUrl() );
- cl.createArg().setFile( workingDirectory );
+ cl.createArg().setValue( workingDirectory.getName() );
return cl;
}
@@ -223,8 +223,8 @@
// A tag will not be pulled but we only fetch all the commits from the upstream repo
// This is done because checking out a tag might not happen on the current branch
// but create a 'detached HEAD'.
- // In fact, a tag in git may be in multiple branches. This occurs if
- // you create a branch after the tag has been created
+ // In fact, a tag in git may be in multiple branches. This occurs if
+ // you create a branch after the tag has been created
cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "fetch" );
cl.createArg().setValue( repository.getFetchUrl() );
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/GitCommandLineUtilsAddTargetTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsAddTargetTest.java
index 6574922..5005cee 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsAddTargetTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/GitCommandLineUtilsAddTargetTest.java
@@ -65,7 +65,7 @@
// https://jira.codehaus.org/browse/SCM-667
final List<File> filesToAdd = Arrays.asList( new File( "C:\\prj\\pom.xml" ),
new File( "c:\\prj\\mod1\\pom.xml" ) );
- final String expectedArguments = "[add, pom.xml, mod1\\pom.xml]";
+ final String expectedArguments = "[add, pom.xml, mod1/pom.xml]";
check( workingDir, filesToAdd, expectedArguments );
}
@@ -108,4 +108,4 @@
{
return Os.isFamily( Os.FAMILY_WINDOWS );
}
-}
\ No newline at end of file
+}
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/changelog/GitChangeLogCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java
index ecc6086..48a8d88 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/changelog/GitChangeLogCommandTest.java
@@ -52,16 +52,14 @@
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", null, (Date) null, (Date) null, 40,
- "git whatchanged --date=iso --max-count=40"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso --max-count=40 -- ." );
}
public void testCommandLineNoDatesLimitedCount()
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", null, (Date) null, (Date) null,
- "git whatchanged --date=iso"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso -- ." );
}
public void testCommandLineWithDates()
@@ -71,8 +69,7 @@
Date endDate = getDate( 2007, Calendar.OCTOBER, 10, GMT_TIME_ZONE );
testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate,
- "git whatchanged \"--since=2003-09-10 00:00:00 +0000\" \"--until=2007-10-10 00:00:00 +0000\" --date=iso"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged \"--since=2003-09-10 00:00:00 +0000\" \"--until=2007-10-10 00:00:00 +0000\" --date=iso -- ." );
}
public void testCommandLineStartDateOnly()
@@ -81,8 +78,7 @@
Date startDate = getDate( 2003, Calendar.SEPTEMBER, 10, 1, 1, 1, GMT_TIME_ZONE );
testCommandLine( "scm:git:http://foo.com/git", null, startDate, null,
- "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" --date=iso"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" --date=iso -- ." );
}
public void testCommandLineDateFormat()
@@ -92,8 +88,7 @@
Date endDate = getDate( 2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE );
testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate,
- "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso -- ." );
}
public void testCommandLineDateVersionRanges()
@@ -103,8 +98,7 @@
Date endDate = getDate( 2005, Calendar.NOVEMBER, 13, 23, 23, 23, GMT_TIME_ZONE );
testCommandLine( "scm:git:http://foo.com/git", null, startDate, endDate, new ScmRevision( "1" ), new ScmRevision( "10" ),
- "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso 1..10"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged \"--since=2003-09-10 01:01:01 +0000\" \"--until=2005-11-13 23:23:23 +0000\" --date=iso 1..10 -- ." );
}
public void testCommandLineEndDateOnly()
@@ -114,16 +108,14 @@
// Only specifying end date should print no dates at all
testCommandLine( "scm:git:http://foo.com/git", null, null, endDate,
- "git whatchanged \"--until=2003-11-10 00:00:00 +0000\" --date=iso"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged \"--until=2003-11-10 00:00:00 +0000\" --date=iso -- ." );
}
public void testCommandLineWithBranchNoDates()
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", new ScmBranch( "my-test-branch" ), (Date) null, (Date) null,
- "git whatchanged --date=iso my-test-branch"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso my-test-branch -- ." );
}
@@ -131,32 +123,28 @@
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), null,
- "git whatchanged --date=iso 1.."
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso 1.. -- ." );
}
public void testCommandLineWithStartVersionAndEndVersion()
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), new ScmRevision( "10" ),
- "git whatchanged --date=iso 1..10"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso 1..10 -- ." );
}
public void testCommandLineWithStartVersionAndEndVersionEquals()
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", null, new ScmRevision( "1" ), new ScmRevision( "1" ),
- "git whatchanged --date=iso 1..1"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso 1..1 -- ." );
}
public void testCommandLineWithStartVersionAndEndVersionAndBranch()
throws Exception
{
testCommandLine( "scm:git:http://foo.com/git", new ScmBranch( "my-test-branch" ), new ScmRevision( "1" ), new ScmRevision( "10" ),
- "git whatchanged --date=iso 1..10 my-test-branch"
- + " -- " + StringUtils.quoteAndEscape( workingDirectory.getPath(), '"' ) );
+ "git whatchanged --date=iso 1..10 my-test-branch -- ." );
}
// ----------------------------------------------------------------------
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java
index 1b42d94..3302557 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/changelog/GitChangeLogCommandTckTest.java
@@ -48,7 +48,7 @@
public void initRepo()
throws Exception
{
- GitScmTestUtils.initRepo( "src/test/resources/linear-changelog/", getRepositoryRoot(), getWorkingDirectory() );
+ GitScmTestUtils.initRepo( "src/test/resources/linear-changelog/", getRepositoryRoot(), getWorkingCopy() );
}
@Override
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java
index ff277b5..12583f6 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/command/update/GitUpdateCommandTckTest.java
@@ -37,7 +37,7 @@
public void initRepo()
throws Exception
{
- GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory() );
+ GitScmTestUtils.initRepo( "src/test/resources/repository/", getRepositoryRoot(), getWorkingCopy() );
}
@Override