From 5b13c1a2e55cb442484d9c7b45389f422b110eec Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Mon, 22 Aug 2016 00:30:50 +0200 Subject: options renamed and some text fixes --- examples/basic/main.go | 2 +- examples/latest/latest.go | 7 ++----- examples/object_storage/main.go | 2 +- examples/object_storage/storage.go | 36 ++++++++++++++++++++++++++++++++++++ examples/remotes/main.go | 2 +- 5 files changed, 41 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/basic/main.go b/examples/basic/main.go index 4c65a70..e192cef 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -16,7 +16,7 @@ func main() { // > git clone https://github.com/git-fixtures/basic.git color.Blue("git clone https://github.com/git-fixtures/basic.git") - r.Clone(&git.RepositoryCloneOptions{ + r.Clone(&git.CloneOptions{ URL: "https://github.com/git-fixtures/basic.git", }) diff --git a/examples/latest/latest.go b/examples/latest/latest.go index de927fa..05f583a 100644 --- a/examples/latest/latest.go +++ b/examples/latest/latest.go @@ -11,12 +11,9 @@ func main() { url := os.Args[1] fmt.Printf("Retrieving latest commit from: %q ...\n", url) - r, err := git.NewMemoryRepository() - if err != nil { - panic(err) - } + r := git.NewMemoryRepository() - if err = r.Clone(&git.RepositoryCloneOptions{URL: url}); err != nil { + if err := r.Clone(&git.CloneOptions{URL: url}); err != nil { panic(err) } diff --git a/examples/object_storage/main.go b/examples/object_storage/main.go index d3818e0..22fa426 100644 --- a/examples/object_storage/main.go +++ b/examples/object_storage/main.go @@ -38,7 +38,7 @@ func clone(r *git.Repository, url string) { fmt.Printf("Cloning %q ...\n", os.Args[2]) start := time.Now() - if err := r.Clone(&git.RepositoryCloneOptions{URL: url}); err != nil { + if err := r.Clone(&git.CloneOptions{URL: url}); err != nil { panic(err) } diff --git a/examples/object_storage/storage.go b/examples/object_storage/storage.go index bb9ff29..c119adc 100644 --- a/examples/object_storage/storage.go +++ b/examples/object_storage/storage.go @@ -5,6 +5,7 @@ import ( "io" "io/ioutil" + "gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/core" "github.com/aerospike/aerospike-client-go" @@ -40,6 +41,10 @@ func (s *AerospikeStorage) ReferenceStorage() core.ReferenceStorage { return s.rs } +func (s *AerospikeStorage) ConfigStorage() config.ConfigStorage { + return &ConfigStorage{} +} + type AerospikeObjectStorage struct { url string client *aerospike.Client @@ -227,3 +232,34 @@ func (s *AerospikeReferenceStorage) Iter() (core.ReferenceIter, error) { return core.NewReferenceSliceIter(refs), nil } + +type ConfigStorage struct { + RemotesConfig map[string]*config.RemoteConfig +} + +func (c *ConfigStorage) Remote(name string) (*config.RemoteConfig, error) { + r, ok := c.RemotesConfig[name] + if ok { + return r, nil + } + + return nil, config.ErrRemoteConfigNotFound +} + +func (c *ConfigStorage) Remotes() ([]*config.RemoteConfig, error) { + var o []*config.RemoteConfig + for _, r := range c.RemotesConfig { + o = append(o, r) + } + + return o, nil +} +func (c *ConfigStorage) SetRemote(r *config.RemoteConfig) error { + c.RemotesConfig[r.Name] = r + return nil +} + +func (c *ConfigStorage) DeleteRemote(name string) error { + delete(c.RemotesConfig, name) + return nil +} diff --git a/examples/remotes/main.go b/examples/remotes/main.go index 488986a..88662cd 100644 --- a/examples/remotes/main.go +++ b/examples/remotes/main.go @@ -37,7 +37,7 @@ func main() { // > git pull example color.Blue("git pull example") - r.Pull(&git.RepositoryPullOptions{ + r.Pull(&git.PullOptions{ RemoteName: "example", }) -- cgit