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

Partial windows support #369

Merged
merged 6 commits into from
Jun 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion plumbing/transport/file/upload_pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
20 changes: 7 additions & 13 deletions plumbing/transport/server/server_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package server_test

import (
"fmt"
"testing"

"github.com/src-d/go-git-fixtures"
Expand All @@ -16,8 +15,6 @@ import (

func Test(t *testing.T) { TestingT(t) }

const inprocScheme = "inproc"

type BaseSuite struct {
fixtures.Suite
loader server.MapLoader
Expand All @@ -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
}
}

Expand All @@ -47,24 +44,21 @@ 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)
c.Assert(err, IsNil)
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
}
6 changes: 3 additions & 3 deletions repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 8 additions & 9 deletions storage/filesystem/internal/dotgit/dotgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions storage/filesystem/internal/dotgit/dotgit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand All @@ -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)
}
3 changes: 2 additions & 1 deletion submodule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down