diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-22 00:30:50 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-22 00:30:50 +0200 |
commit | 5b13c1a2e55cb442484d9c7b45389f422b110eec (patch) | |
tree | 9be0949cb354dfd6521aa84f4af9e5777c3a1cef /examples | |
parent | f42d82364c5d159f65a48e720433ad2bc97f0b7f (diff) | |
download | go-git-5b13c1a2e55cb442484d9c7b45389f422b110eec.tar.gz |
options renamed and some text fixes
Diffstat (limited to 'examples')
-rw-r--r-- | examples/basic/main.go | 2 | ||||
-rw-r--r-- | examples/latest/latest.go | 7 | ||||
-rw-r--r-- | examples/object_storage/main.go | 2 | ||||
-rw-r--r-- | examples/object_storage/storage.go | 36 | ||||
-rw-r--r-- | examples/remotes/main.go | 2 |
5 files changed, 41 insertions, 8 deletions
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", }) |