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/08/12 20:02:19 UTC

[maven-scm] branch path-fiddle created (now a1b1035)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch path-fiddle
in repository https://gitbox.apache.org/repos/asf/maven-scm.git.


      at a1b1035  Use NIO2 Path for clean URIs

This branch includes the following new commits:

     new a1b1035  Use NIO2 Path for clean URIs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-scm] 01/01: Use NIO2 Path for clean URIs

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch path-fiddle
in repository https://gitbox.apache.org/repos/asf/maven-scm.git

commit a1b103519dd0c56931fea692997ebaa40d36df18
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Aug 12 22:01:57 2018 +0200

    Use NIO2 Path for clean URIs
---
 .../checkin/GitCheckInCommandNoBranchTest.java     |  2 +-
 .../command/checkin/GitCheckInCommandTest.java     | 14 +++---
 .../GitExeCheckOutCommandNoBranchTest.java         |  2 +-
 .../maven/scm/provider/git/GitScmTestUtils.java    | 51 ++++------------------
 4 files changed, 18 insertions(+), 51 deletions(-)

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/checkin/GitCheckInCommandNoBranchTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java
index e73e163..d5f722b 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandNoBranchTest.java
@@ -61,7 +61,7 @@ public class GitCheckInCommandNoBranchTest
         FileUtils.deleteDirectory( repo );
         FileUtils.copyDirectoryStructure( repo_orig, repo );
 
-        ScmRepository scmRepository = getScmManager().makeScmRepository( "scm:git:file:///" + repo.getAbsolutePath() );
+        ScmRepository scmRepository = getScmManager().makeScmRepository( "scm:git:" + repo.toPath().toUri().toASCIIString() );
 
         CheckOutScmResult checkOutScmResult = checkoutRepo( scmRepository );
 
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/checkin/GitCheckInCommandTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java
index 3221fc6..4dccb9e 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkin/GitCheckInCommandTest.java
@@ -65,7 +65,7 @@ public class GitCheckInCommandTest
     {
         if ( GitUtil.getSettings().isCommitNoVerify() )
         {
-            testCommandLine( "scm:git:http://foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a" + " --no-verify" );    
+            testCommandLine( "scm:git:http://foo.com/git/trunk", "git commit --verbose " + messageFileString + " -a" + " --no-verify" );
         }
         else
         {
@@ -95,18 +95,18 @@ public class GitCheckInCommandTest
 
         GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory());
 
-        ScmRepository scmRepository = getScmManager().makeScmRepository( "scm:git:file://" + repo.getAbsolutePath() );
+        ScmRepository scmRepository = getScmManager().makeScmRepository( "scm:git:" + repo.toPath().toUri().toASCIIString() );
         checkoutRepoInto(checkedOutRepo, scmRepository);
 
         // Add a default user to the config
         GitScmTestUtils.setDefaultUser( checkedOutRepo );
 
         // Creating foo/bar/wine.xml
-        File fooDir = new File( checkedOutRepo.getAbsolutePath() + File.separator + "foo" );
+        File fooDir = new File( checkedOutRepo.getAbsolutePath(), "foo" );
         fooDir.mkdir();
-        File barDir = new File(fooDir.getAbsolutePath() + File.separator + "bar");
+        File barDir = new File(fooDir.getAbsolutePath(), "bar");
         barDir.mkdir();
-        File wineFile = new File(barDir.getAbsolutePath() + File.separator + "wine.xml");
+        File wineFile = new File(barDir.getAbsolutePath(), "wine.xml");
         FileUtils.fileWrite( wineFile.getAbsolutePath(), "Lacoste castle" );
 
         // Adding and commiting file
@@ -116,9 +116,9 @@ public class GitCheckInCommandTest
         assertResultIsSuccess( checkInScmResult );
 
         // Cloning foo/bar/wine.xml to foo/newbar/wine.xml
-        File newBarDir = new File(fooDir.getAbsolutePath() + File.separator + "newbar");
+        File newBarDir = new File(fooDir.getAbsolutePath(), "newbar");
         newBarDir.mkdir();
-        File movedWineFile = new File(newBarDir.getAbsolutePath() + File.separator + "wine.xml");
+        File movedWineFile = new File(newBarDir.getAbsolutePath(), "wine.xml");
         FileUtils.copyFile(wineFile, movedWineFile);
 
         // Removing old file, adding new file and commiting...
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/checkout/GitExeCheckOutCommandNoBranchTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java
index 0d1c959..c442d59 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/checkout/GitExeCheckOutCommandNoBranchTest.java
@@ -50,7 +50,7 @@ public class GitExeCheckOutCommandNoBranchTest
         FileUtils.deleteDirectory( workingDirectory );
         repo = new File( "src/test/resources/repository_no_branch" );
 
-        scmRepository = getScmManager().makeScmRepository( "scm:git:file:///" + repo.getAbsolutePath() );
+        scmRepository = getScmManager().makeScmRepository( "scm:git:" + repo.toPath().toUri().toASCIIString() );
     }
 
     public void testCheckoutNoBranch()
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
index c62458f..0a05a63 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gittest/src/main/java/org/apache/maven/scm/provider/git/GitScmTestUtils.java
@@ -1,5 +1,13 @@
 package org.apache.maven.scm.provider.git;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,17 +28,6 @@ package org.apache.maven.scm.provider.git;
  */
 
 import junit.framework.Assert;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.Os;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -79,37 +76,7 @@ public final class GitScmTestUtils
     public static String getScmUrl( File repositoryRootFile, String provider )
         throws CommandLineException
     {
-        String repositoryRoot = repositoryRootFile.getAbsolutePath();
-
-        // TODO: it'd be great to build this into CommandLineUtils somehow
-        // TODO: some way without a custom cygwin sys property?
-        if ( "true".equals( System.getProperty( "cygwin" ) ) )
-        {
-            Commandline cl = new Commandline();
-
-            cl.setExecutable( "cygpath" );
-
-            cl.createArg().setValue( "--unix" );
-
-            cl.createArg().setValue( repositoryRoot );
-
-            CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
-
-            int exitValue = CommandLineUtils.executeCommandLine( cl, stdout, null );
-
-            if ( exitValue != 0 )
-            {
-                throw new CommandLineException( "Unable to convert cygwin path, exit code = " + exitValue );
-            }
-
-            repositoryRoot = stdout.getOutput().trim();
-        }
-        else if ( Os.isFamily( "windows" ) )
-        {
-            repositoryRoot = "/" + StringUtils.replace( repositoryRoot, "\\", "/" );
-        }
-
-        return "scm:" + provider + ":file://" + repositoryRoot;
+        return "scm:" + provider + ":" + repositoryRootFile.toPath().toUri().toASCIIString();
     }