diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-01-29 02:27:16 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-01-29 22:36:15 +0100 |
commit | acb1dc80d93f45a055b14903679abca3a6e994f6 (patch) | |
tree | a7e29fd677bb5c11df85fca1fcb6d015bc40fa7b /examples/storage/main.go | |
parent | 352170d1bf8cc7b32b85d8a2740eb3627e952a6e (diff) | |
download | go-git-acb1dc80d93f45a055b14903679abca3a6e994f6.tar.gz |
example: using new constructors
Diffstat (limited to 'examples/storage/main.go')
-rw-r--r-- | examples/storage/main.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/examples/storage/main.go b/examples/storage/main.go index b047e43..05752a1 100644 --- a/examples/storage/main.go +++ b/examples/storage/main.go @@ -26,30 +26,31 @@ func main() { s, err := aerospike.NewStorage(client, "test", url) CheckIfError(err) - // A new repository instance using as storage the custom implementation - r, err := git.NewRepository(s) - CheckIfError(err) - switch action { case "clone": - clone(r, url) + clone(s, url) case "log": - log(r) + log(s) default: panic("unknown option") } } -func clone(r *git.Repository, url string) { +func clone(s git.Storer, url string) { // Clone the given repository, all the objects, references and - // configuration sush as remotes, are save into the Aerospike database. + // configuration sush as remotes, are save into the Aerospike database + // using the custom storer Info("git clone %s", url) - err := r.Clone(&git.CloneOptions{URL: url}) + _, err := git.Clone(s, nil, &git.CloneOptions{URL: url}) CheckIfError(err) } -func log(r *git.Repository) { +func log(s git.Storer) { + // We open the repository using as storer the custom implementation + r, err := git.Open(s, nil) + CheckIfError(err) + // Prints the history of the repository starting in the current HEAD, the // objects are retrieved from Aerospike database. Info("git log --oneline") |