aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-06-17 12:53:39 +0200
committerGitHub <noreply@github.com>2017-06-17 12:53:39 +0200
commit86f6ba1dea8972df7c017e01ddb2c097892bc220 (patch)
treea7add5abd733fbc4362d80eecd5fa16f23a21901
parentbf3a92052f715c507ace0cb9f2b7fb358f623abc (diff)
parentaba32ceed59d77c84038fa421b230e1ea76a5e6b (diff)
downloadgo-git-86f6ba1dea8972df7c017e01ddb2c097892bc220.tar.gz
Merge pull request #369 from smola/windows
Windows support
-rw-r--r--appveyor.yml3
-rw-r--r--plumbing/transport/file/upload_pack_test.go3
-rw-r--r--plumbing/transport/server/server_test.go20
-rw-r--r--repository_test.go6
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go17
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_test.go4
-rw-r--r--submodule_test.go3
7 files changed, 25 insertions, 31 deletions
diff --git a/appveyor.yml b/appveyor.yml
index f36ebe7..160616b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,10 +11,9 @@ environment:
GOPATH: c:\gopath
install:
- - set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
+ - set PATH=%GOPATH%\bin;c:\go\bin;"C:\Program Files\Git\mingw64\bin";%PATH%
- go version
- go get -v -t ./...
-
- git config --global user.email "travis@example.com"
- git config --global user.name "Travis CI
diff --git a/plumbing/transport/file/upload_pack_test.go b/plumbing/transport/file/upload_pack_test.go
index f013683..f953e02 100644
--- a/plumbing/transport/file/upload_pack_test.go
+++ b/plumbing/transport/file/upload_pack_test.go
@@ -74,6 +74,7 @@ func (s *UploadPackSuite) TestNonExistentCommand(c *C) {
cmd := "/non-existent-git"
client := NewClient(cmd, cmd)
session, err := client.NewUploadPackSession(s.Endpoint, s.EmptyAuth)
- c.Assert(err, ErrorMatches, ".*no such file or directory.*")
+ // Error message is OS-dependant, so do a broad check
+ c.Assert(err, ErrorMatches, ".*file.*")
c.Assert(session, IsNil)
}
diff --git a/plumbing/transport/server/server_test.go b/plumbing/transport/server/server_test.go
index 6a64674..5e7d234 100644
--- a/plumbing/transport/server/server_test.go
+++ b/plumbing/transport/server/server_test.go
@@ -1,7 +1,6 @@
package server_test
import (
- "fmt"
"testing"
"github.com/src-d/go-git-fixtures"
@@ -16,8 +15,6 @@ import (
func Test(t *testing.T) { TestingT(t) }
-const inprocScheme = "inproc"
-
type BaseSuite struct {
fixtures.Suite
loader server.MapLoader
@@ -29,15 +26,15 @@ func (s *BaseSuite) SetUpSuite(c *C) {
s.Suite.SetUpSuite(c)
s.loader = server.MapLoader{}
s.client = server.NewServer(s.loader)
- s.clientBackup = client.Protocols[inprocScheme]
- client.Protocols[inprocScheme] = s.client
+ s.clientBackup = client.Protocols["file"]
+ client.Protocols["file"] = s.client
}
func (s *BaseSuite) TearDownSuite(c *C) {
if s.clientBackup == nil {
- delete(client.Protocols, inprocScheme)
+ delete(client.Protocols, "file")
} else {
- client.Protocols[inprocScheme] = s.clientBackup
+ client.Protocols["file"] = s.clientBackup
}
}
@@ -47,8 +44,7 @@ func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint,
f := fixtures.Basic().One()
fs := f.DotGit()
path := fs.Base()
- url := fmt.Sprintf("%s://%s", inprocScheme, path)
- ep, err := transport.NewEndpoint(url)
+ ep, err := transport.NewEndpoint(path)
c.Assert(err, IsNil)
*basic = ep
sto, err := filesystem.NewStorage(fs)
@@ -56,15 +52,13 @@ func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint,
s.loader[ep.String()] = sto
path = "/empty.git"
- url = fmt.Sprintf("%s://%s", inprocScheme, path)
- ep, err = transport.NewEndpoint(url)
+ ep, err = transport.NewEndpoint(path)
c.Assert(err, IsNil)
*empty = ep
s.loader[ep.String()] = memory.NewStorage()
path = "/non-existent.git"
- url = fmt.Sprintf("%s://%s", inprocScheme, path)
- ep, err = transport.NewEndpoint(url)
+ ep, err = transport.NewEndpoint(path)
c.Assert(err, IsNil)
*nonExistent = ep
}
diff --git a/repository_test.go b/repository_test.go
index deb3f58..a1b92ae 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -51,16 +51,16 @@ func (s *RepositorySuite) TestInitNonStandardDotGit(c *C) {
c.Assert(err, IsNil)
c.Assert(r, NotNil)
- f, err := fs.Open("worktree/.git")
+ f, err := fs.Open(fs.Join("worktree", ".git"))
c.Assert(err, IsNil)
all, err := ioutil.ReadAll(f)
c.Assert(err, IsNil)
- c.Assert(string(all), Equals, "gitdir: ../storage\n")
+ c.Assert(string(all), Equals, fmt.Sprintf("gitdir: %s\n", filepath.Join("..", "storage")))
cfg, err := r.Config()
c.Assert(err, IsNil)
- c.Assert(cfg.Core.Worktree, Equals, "../worktree")
+ c.Assert(cfg.Core.Worktree, Equals, filepath.Join("..", "worktree"))
}
func (s *RepositorySuite) TestInitStandardDotGit(c *C) {
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 1af64ab..827c18d 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -413,11 +413,11 @@ func (d *DotGit) processLine(line string) (*plumbing.Reference, error) {
}
func (d *DotGit) addRefsFromRefDir(refs *[]*plumbing.Reference) error {
- return d.walkReferencesTree(refs, refsPath)
+ return d.walkReferencesTree(refs, []string{refsPath})
}
-func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string) error {
- files, err := d.fs.ReadDir(relPath)
+func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath []string) error {
+ files, err := d.fs.ReadDir(d.fs.Join(relPath...))
if err != nil {
if os.IsNotExist(err) {
return nil
@@ -427,7 +427,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
}
for _, f := range files {
- newRelPath := d.fs.Join(relPath, f.Name())
+ newRelPath := append(append([]string(nil), relPath...), f.Name())
if f.IsDir() {
if err = d.walkReferencesTree(refs, newRelPath); err != nil {
return err
@@ -436,7 +436,7 @@ func (d *DotGit) walkReferencesTree(refs *[]*plumbing.Reference, relPath string)
continue
}
- ref, err := d.readReferenceFile(".", newRelPath)
+ ref, err := d.readReferenceFile(".", strings.Join(newRelPath, "/"))
if err != nil {
return err
}
@@ -463,9 +463,8 @@ func (d *DotGit) addRefFromHEAD(refs *[]*plumbing.Reference) error {
return nil
}
-func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Reference, err error) {
- path := d.fs.Join(refsPath, refFile)
-
+func (d *DotGit) readReferenceFile(path, name string) (ref *plumbing.Reference, err error) {
+ path = d.fs.Join(path, d.fs.Join(strings.Split(name, "/")...))
f, err := d.fs.Open(path)
if err != nil {
return nil, err
@@ -478,7 +477,7 @@ func (d *DotGit) readReferenceFile(refsPath, refFile string) (ref *plumbing.Refe
}
line := strings.TrimSpace(string(b))
- return plumbing.NewReferenceFromStrings(refFile, line), nil
+ return plumbing.NewReferenceFromStrings(name, line), nil
}
// Module return a billy.Filesystem poiting to the module folder
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go
index f06f908..e1667af 100644
--- a/storage/filesystem/internal/dotgit/dotgit_test.go
+++ b/storage/filesystem/internal/dotgit/dotgit_test.go
@@ -445,7 +445,7 @@ func (s *SuiteDotGit) TestObject(c *C) {
file, err := dir.Object(hash)
c.Assert(err, IsNil)
c.Assert(strings.HasSuffix(
- file.Filename(), "objects/03/db8e1fbe133a480f2867aac478fd866686d69e"),
+ file.Filename(), fs.Join("objects", "03", "db8e1fbe133a480f2867aac478fd866686d69e")),
Equals, true,
)
}
@@ -465,5 +465,5 @@ func (s *SuiteDotGit) TestSubmodules(c *C) {
dir := New(fs)
m := dir.Module("basic")
- c.Assert(strings.HasSuffix(m.Base(), ".git/module/basic"), Equals, true)
+ c.Assert(strings.HasSuffix(m.Base(), m.Join(".git", "module", "basic")), Equals, true)
}
diff --git a/submodule_test.go b/submodule_test.go
index fdbe4a8..2d3f7a6 100644
--- a/submodule_test.go
+++ b/submodule_test.go
@@ -127,7 +127,8 @@ func (s *SubmoduleSuite) TestUpdateWithRecursion(c *C) {
c.Assert(err, IsNil)
- _, err = s.Worktree.fs.Stat("itself/basic/LICENSE")
+ fs := s.Worktree.fs
+ _, err = fs.Stat(fs.Join("itself", "basic", "LICENSE"))
c.Assert(err, IsNil)
}