aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-20 01:30:05 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-20 01:30:05 +0200
commit4652c0e753c88e63ba111d49aa58edc655806c03 (patch)
tree28d8570676de3d0b5802c265406a82d5ba2bf842 /repository.go
parent9f49aaed839ae608a0ffdaa0656b3975d3404002 (diff)
downloadgo-git-4652c0e753c88e63ba111d49aa58edc655806c03.tar.gz
remote and repository base on ConfigStore
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/repository.go b/repository.go
index ada0bc4..d36ca05 100644
--- a/repository.go
+++ b/repository.go
@@ -3,11 +3,9 @@ package git
import (
"errors"
- "gopkg.in/src-d/go-git.v4/clients/common"
+ "gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/core"
- "gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/memory"
- "gopkg.in/src-d/go-git.v4/utils/fs"
)
var (
@@ -19,7 +17,7 @@ var (
// Repository giturl string, auth common.AuthMethod repository struct
type Repository struct {
Remotes map[string]*Remote
- s core.Storage
+ s Storage
}
// NewMemoryRepository creates a new repository, backed by a memory.Storage
@@ -27,6 +25,7 @@ func NewMemoryRepository() (*Repository, error) {
return NewRepository(memory.NewStorage())
}
+/*
// NewFilesystemRepository creates a new repository, backed by a filesystem.Storage
// based on a fs.OS, if you want to use a custom one you need to use the function
// NewRepository and build you filesystem.Storage
@@ -38,9 +37,10 @@ func NewFilesystemRepository(path string) (*Repository, error) {
return NewRepository(s)
}
+*/
// NewRepository creates a new repository with the given Storage
-func NewRepository(s core.Storage) (*Repository, error) {
+func NewRepository(s Storage) (*Repository, error) {
return &Repository{s: s}, nil
}
@@ -50,7 +50,11 @@ func (r *Repository) Clone(o *RepositoryCloneOptions) error {
return err
}
- remote, err := r.createRemote(o.RemoteName, o.URL, o.Auth)
+ remote, err := r.createRemote(&config.RemoteConfig{
+ Name: o.RemoteName,
+ URL: o.URL,
+ })
+
if err != nil {
return err
}
@@ -66,7 +70,7 @@ func (r *Repository) Clone(o *RepositoryCloneOptions) error {
return err
}
- err = remote.Fetch(r.s, &RemoteFetchOptions{
+ err = remote.Fetch(&RemoteFetchOptions{
RefSpec: spec,
Depth: o.Depth,
})
@@ -83,13 +87,10 @@ func (r *Repository) Clone(o *RepositoryCloneOptions) error {
return r.createReferences(head)
}
-func (r *Repository) createRemote(name, url string, auth common.AuthMethod) (*Remote, error) {
- remote, err := NewAuthenticatedRemote(name, url, auth)
- if err != nil {
- return nil, err
- }
+func (r *Repository) createRemote(c *config.RemoteConfig) (*Remote, error) {
+ remote := NewRemote(r.s, c)
- r.Remotes = map[string]*Remote{name: remote}
+ r.Remotes = map[string]*Remote{c.Name: remote}
return remote, nil
}
@@ -130,7 +131,7 @@ func (r *Repository) Pull(o *RepositoryPullOptions) error {
defer remote.Disconnect()
- err = remote.Fetch(r.s, &RemoteFetchOptions{
+ err = remote.Fetch(&RemoteFetchOptions{
Depth: o.Depth,
})