Beispiel #1
0
func (s *FetchPackSuite) SetUpSuite(c *C) {
	s.Suite.SetUpSuite(c)

	if err := exec.Command("git", "--version").Run(); err != nil {
		c.Skip("git command not found")
	}

	s.FetchPackSuite.Client = DefaultClient

	fixture := fixtures.Basic().One()
	path := fixture.DotGit().Base()
	url := fmt.Sprintf("file://%s", path)
	ep, err := transport.NewEndpoint(url)
	c.Assert(err, IsNil)
	s.Endpoint = ep

	fixture = fixtures.ByTag("empty").One()
	path = fixture.DotGit().Base()
	url = fmt.Sprintf("file://%s", path)
	ep, err = transport.NewEndpoint(url)
	c.Assert(err, IsNil)
	s.EmptyEndpoint = ep

	url = fmt.Sprintf("file://%s/%s", fixtures.DataFolder, "non-existent")
	ep, err = transport.NewEndpoint(url)
	c.Assert(err, IsNil)
	s.NonExistentEndpoint = ep
}
Beispiel #2
0
func (s *FetchPackSuite) SetUpSuite(c *C) {
	s.FetchPackSuite.Client = DefaultClient

	ep, err := transport.NewEndpoint("https://github.com/git-fixtures/basic.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.Endpoint = ep

	ep, err = transport.NewEndpoint("https://github.com/git-fixtures/empty.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.EmptyEndpoint = ep

	ep, err = transport.NewEndpoint("https://github.com/git-fixtures/non-existent.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.NonExistentEndpoint = ep
}
Beispiel #3
0
func (s *ClientSuite) TestNewClientHTTP(c *C) {
	e, err := transport.NewEndpoint("http://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	output, err := NewClient(e)
	c.Assert(err, IsNil)
	c.Assert(typeAsString(output), Equals, "*http.client")

	e, err = transport.NewEndpoint("https://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	output, err = NewClient(e)
	c.Assert(err, IsNil)
	c.Assert(typeAsString(output), Equals, "*http.client")
}
Beispiel #4
0
func (s *ClientSuite) TestNewClientUnknown(c *C) {
	e, err := transport.NewEndpoint("unknown://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	_, err = NewClient(e)
	c.Assert(err, NotNil)
}
Beispiel #5
0
func (s *ClientSuite) SetUpSuite(c *C) {
	var err error
	s.Endpoint, err = transport.NewEndpoint(
		"https://github.com/git-fixtures/basic",
	)
	c.Assert(err, IsNil)
}
Beispiel #6
0
func (s *ClientSuite) TestNewClientSSH(c *C) {
	e, err := transport.NewEndpoint("ssh://github.com/src-d/go-git")
	c.Assert(err, IsNil)

	output, err := NewClient(e)
	c.Assert(err, IsNil)
	c.Assert(output, NotNil)
}
Beispiel #7
0
func (s *FetchPackSuite) SetUpSuite(c *C) {
	if os.Getenv("SSH_AUTH_SOCK") == "" {
		c.Skip("SSH_AUTH_SOCK is not set")
	}

	s.FetchPackSuite.Client = DefaultClient

	ep, err := transport.NewEndpoint("[email protected]:git-fixtures/basic.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.Endpoint = ep

	ep, err = transport.NewEndpoint("[email protected]:git-fixtures/empty.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.EmptyEndpoint = ep

	ep, err = transport.NewEndpoint("[email protected]:git-fixtures/non-existent.git")
	c.Assert(err, IsNil)
	s.FetchPackSuite.NonExistentEndpoint = ep

}
Beispiel #8
0
func newClient(url string) (transport.Client, transport.Endpoint, error) {
	ep, err := transport.NewEndpoint(url)
	if err != nil {
		return nil, transport.Endpoint{}, err
	}

	c, err := client.NewClient(ep)
	if err != nil {
		return nil, transport.Endpoint{}, err
	}

	return c, ep, err
}
Beispiel #9
0
func prepareRepo(c *C, path string) transport.Endpoint {
	url := fmt.Sprintf("file://%s", path)
	ep, err := transport.NewEndpoint(url)
	c.Assert(err, IsNil)

	// git-receive-pack refuses to update refs/heads/master on non-bare repo
	// so we ensure bare repo config.
	config := fmt.Sprintf("%s/config", path)
	if _, err := os.Stat(config); err == nil {
		f, err := os.OpenFile(config, os.O_TRUNC|os.O_WRONLY, 0)
		c.Assert(err, IsNil)
		content := strings.NewReader(bareConfig)
		_, err = io.Copy(f, content)
		c.Assert(err, IsNil)
		c.Assert(f.Close(), IsNil)
	}

	return ep
}