aboutsummaryrefslogtreecommitdiffstats
path: root/examples/storage/main.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-01-30 22:03:19 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-30 22:03:19 +0100
commit80179adaab815eaf75099a5ff31e48c6bd07d1dc (patch)
tree8973e44f42a5dc71054a4a45997a29103530ae17 /examples/storage/main.go
parente80d7b7267ba9f2057f259be331c4de927a60ecb (diff)
downloadgo-git-80179adaab815eaf75099a5ff31e48c6bd07d1dc.tar.gz
rename billy imports
Diffstat (limited to 'examples/storage/main.go')
-rw-r--r--examples/storage/main.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/examples/storage/main.go b/examples/storage/main.go
deleted file mode 100644
index 05752a1..0000000
--- a/examples/storage/main.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package main
-
-import (
- "fmt"
- "os"
- "strings"
-
- "gopkg.in/src-d/go-git.v4"
- . "gopkg.in/src-d/go-git.v4/examples"
- "gopkg.in/src-d/go-git.v4/examples/storage/aerospike"
-
- driver "github.com/aerospike/aerospike-client-go"
-)
-
-func main() {
- CheckArgs("<clone|log>", "<url>")
- action := os.Args[1]
- url := os.Args[2]
-
- // Aerospike client to be used by the custom storage
- client, err := driver.NewClient("127.0.0.1", 3000)
- CheckIfError(err)
-
- // New instance of the custom aerospike storage, all the objects,
- // references and configuration is saved to aerospike
- s, err := aerospike.NewStorage(client, "test", url)
- CheckIfError(err)
-
- switch action {
- case "clone":
- clone(s, url)
- case "log":
- log(s)
- default:
- panic("unknown option")
- }
-}
-
-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
- // using the custom storer
- Info("git clone %s", url)
-
- _, err := git.Clone(s, nil, &git.CloneOptions{URL: url})
- CheckIfError(err)
-}
-
-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")
-
- ref, err := r.Head()
- CheckIfError(err)
- commit, err := r.Commit(ref.Hash())
- CheckIfError(err)
- commits, err := commit.History()
- CheckIfError(err)
-
- for _, c := range commits {
- hash := c.Hash.String()
- line := strings.Split(c.Message, "\n")
- fmt.Println(hash[:7], line[0])
- }
-}