Skip to content

Commit

Permalink
fix style tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fisher committed Mar 5, 2018
1 parent 6f1c6d1 commit dfb47ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,20 @@ func (s *GitRepo) Ping() bool {

// EscapePathSeparator escapes the path separator by replacing it with several.
// Note: this is harmless on Unix, and needed on Windows.
func EscapePathSeparator(path string) (string) {
func EscapePathSeparator(path string) string {
switch runtime.GOOS {
case `windows`:
// On Windows, triple all path separators.
// Needed to escape backslash(s) preceding doublequotes,
// because of how Windows strings treats backslash+doublequote combo,
// and Go seems to be implicitly passing around a doublequoted string on Windows,
// so we cannnot use default string instead.
// so we cannot use default string instead.
// See: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
// e.g., C:\foo\bar\ -> C:\\\foo\\\bar\\\
// used with --prefix, like this: --prefix=C:\foo\bar\ -> --prefix=C:\\\foo\\\bar\\\
return strings.Replace(path,
string(os.PathSeparator),
string(os.PathSeparator) + string(os.PathSeparator) + string(os.PathSeparator),
string(os.PathSeparator)+string(os.PathSeparator)+string(os.PathSeparator),
-1)
default:
return path
Expand All @@ -404,15 +404,15 @@ func (s *GitRepo) ExportDir(dir string) error {
return NewLocalError("Unable to create directory", err, "")
}

path = EscapePathSeparator( dir )
path = EscapePathSeparator(dir)
out, err := s.RunFromDir("git", "checkout-index", "-f", "-a", "--prefix="+path)
s.log(out)
if err != nil {
return NewLocalError("Unable to export source", err, string(out))
}

// and now, the horror of submodules
path = EscapePathSeparator( dir + "$path" + string(os.PathSeparator) )
path = EscapePathSeparator(dir + "$path" + string(os.PathSeparator))
out, err = s.RunFromDir("git", "submodule", "foreach", "--recursive", "git checkout-index -f -a --prefix="+path)
s.log(out)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ func TestGitSubmoduleHandling2(t *testing.T) {
t.Errorf("Current failed to detect Git on tip of master. Got version: %s", v)
}


tempDir2, err := ioutil.TempDir("", "go-vcs-git-tests-export")
if err != nil {
t.Fatalf("Error creating temp directory: %s", err)
Expand All @@ -583,7 +582,7 @@ func TestGitSubmoduleHandling2(t *testing.T) {
t.Errorf("Error checking exported file in Git: %s", err)
}

_, err = os.Stat(filepath.Join( filepath.Join(exportDir, "definitions"), "README.md"))
_, err = os.Stat(filepath.Join(filepath.Join(exportDir, "definitions"), "README.md"))
if err != nil {
t.Errorf("Error checking exported file in Git: %s", err)
}
Expand Down

0 comments on commit dfb47ae

Please sign in to comment.