Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit b29ccd9

Browse files
mcarmonaamcuadros
authored andcommitted
*: windows support, some more fixes (#533)
* fixed windows failed test: "134 FAIL: repository_test.go:340: RepositorySuite.TestPlainOpenBareRelativeGitDirFileTrailingGarbage" * fixed windows failed test: "143 FAIL: worktree_test.go:367: WorktreeSuite.TestCheckoutIndexOS" * fixed windows failed test: "296 FAIL: receive_pack_test.go:36: ReceivePackSuite.TearDownTest" * fixed windows failed test: "152 FAIL: worktree_test.go:278: WorktreeSuite.TestCheckoutSymlink"
1 parent 3713791 commit b29ccd9

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

plumbing/transport/file/receive_pack_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ func (s *ReceivePackSuite) TestNonExistentCommand(c *C) {
7070
cmd := "/non-existent-git"
7171
client := NewClient(cmd, cmd)
7272
session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth)
73-
c.Assert(err, ErrorMatches, ".*no such file or directory.*")
73+
c.Assert(err, ErrorMatches, ".*(no such file or directory.*|.*file does not exist)*.")
7474
c.Assert(session, IsNil)
7575
}

plumbing/transport/test/receive_pack.go

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func (s *ReceivePackSuite) TestAdvertisedReferencesNotExists(c *C) {
6161

6262
func (s *ReceivePackSuite) TestCallAdvertisedReferenceTwice(c *C) {
6363
r, err := s.Client.NewReceivePackSession(s.Endpoint, s.EmptyAuth)
64+
defer func() { c.Assert(r.Close(), IsNil) }()
6465
c.Assert(err, IsNil)
6566
ar1, err := r.AdvertisedReferences()
6667
c.Assert(err, IsNil)

repository.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func dotGitFileToOSFilesystem(path string, fs billy.Filesystem) (billy.Filesyste
286286
return nil, fmt.Errorf(".git file has no %s prefix", prefix)
287287
}
288288

289-
gitdir := line[len(prefix):]
289+
gitdir := strings.Split(line[len(prefix):], "\n")[0]
290290
gitdir = strings.TrimSpace(gitdir)
291291
if filepath.IsAbs(gitdir) {
292292
return osfs.New(gitdir), nil

repository_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func (s *RepositorySuite) TestPlainOpenBareRelativeGitDirFileTrailingGarbage(c *
348348

349349
altDir, err := ioutil.TempDir("", "plain-open")
350350
c.Assert(err, IsNil)
351-
err = ioutil.WriteFile(filepath.Join(altDir, ".git"), []byte(fmt.Sprintf("gitdir: %s\nTRAILING", dir)), 0644)
351+
err = ioutil.WriteFile(filepath.Join(altDir, ".git"), []byte(fmt.Sprintf("gitdir: %s\nTRAILING", altDir)), 0644)
352352
c.Assert(err, IsNil)
353353

354354
r, err = PlainOpen(altDir)

worktree_test.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io/ioutil"
77
"os"
88
"path/filepath"
9+
"runtime"
910

1011
"golang.org/x/text/unicode/norm"
1112

@@ -278,6 +279,10 @@ func (s *WorktreeSuite) TestCheckout(c *C) {
278279
}
279280

280281
func (s *WorktreeSuite) TestCheckoutSymlink(c *C) {
282+
if runtime.GOOS == "windows" {
283+
c.Skip("git doesn't support symlinks by default in windows")
284+
}
285+
281286
dir, err := ioutil.TempDir("", "checkout")
282287
defer os.RemoveAll(dir)
283288

@@ -430,10 +435,12 @@ func (s *WorktreeSuite) TestCheckoutIndexOS(c *C) {
430435
c.Assert(idx.Entries[0].Size, Equals, uint32(189))
431436

432437
c.Assert(idx.Entries[0].CreatedAt.IsZero(), Equals, false)
433-
c.Assert(idx.Entries[0].Dev, Not(Equals), uint32(0))
434-
c.Assert(idx.Entries[0].Inode, Not(Equals), uint32(0))
435-
c.Assert(idx.Entries[0].UID, Not(Equals), uint32(0))
436-
c.Assert(idx.Entries[0].GID, Not(Equals), uint32(0))
438+
if runtime.GOOS != "windows" {
439+
c.Assert(idx.Entries[0].Dev, Not(Equals), uint32(0))
440+
c.Assert(idx.Entries[0].Inode, Not(Equals), uint32(0))
441+
c.Assert(idx.Entries[0].UID, Not(Equals), uint32(0))
442+
c.Assert(idx.Entries[0].GID, Not(Equals), uint32(0))
443+
}
437444
}
438445

439446
func (s *WorktreeSuite) TestCheckoutBranch(c *C) {

0 commit comments

Comments
 (0)