fork of go-git with some jj specific features
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v4.7.0 107 lines 4.9 kB view raw view rendered
1# go-git + aerospike: a git repository backed by a database 2 3<img src="https://upload.wikimedia.org/wikipedia/en/2/2b/Aerospike_logo.png" align="right"/> This is an example of a [go-git](https://github.com/src-d/go-git) repository backed by [Aerospike](http://www.aerospike.com/). 4 5 6 7 8### and what this means ... 9*git* has as very well defined storage system, the `.git` directory, present on any repository. This is the place where `git` stores al the [`objects`](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects), [`references`](https://git-scm.com/book/es/v2/Git-Internals-Git-References) and [`configuration`](https://git-scm.com/docs/git-config#_configuration_file). This information is stored in plain files. 10 11Our original **go-git** version was designed to work in memory, some time after we added support to read the `.git`, and now we have added support for fully customized [storages](https://godoc.org/gopkg.in/src-d/go-git.v4/storage#Storer). 12 13This means that the internal database of any repository can be saved and accessed on any support, databases, distributed filesystems, etc. This functionality is pretty similar to the [libgit2 backends](http://blog.deveo.com/your-git-repository-in-a-database-pluggable-backends-in-libgit2/) 14 15 16Installation 17------------ 18 19What do you need? You need an *aerospike* server. The easiest way to get one for testing is running the official **docker** container provided by Aerospike: 20 21``` 22docker run -d -p 3000:3000 --name aerospike aerospike/aerospike-server 23``` 24 25Now, we need the sample code. 26 27``` 28go get -u github.com/mcuadros/go-git-aerospike/... 29``` 30 31Running this command will make the binary `go-git-aerospike`. if you have `GOPATH` on your `PATH`, you are ready to go. If not, this is a great moment. 32 33Usage 34----- 35 36### Cloning the repository into the database 37 38Running the command `go-git-aerospike` with the `clone` option followed by the URL of a git repository clones the repository into the database, storing all the git objects in it: 39 40```sh 41go-git-aerospike clone https://github.com/src-d/flamingo.git 42``` 43 44The repository is stored in the aerospike database. This means that all the internal objects like commits, trees, blobs and tags are `records` in different `sets` in the `test` namespace: 45 46```sql 47aql> SELECT hash, type, url FROM test.commit 48``` 49 50``` 51+--------------------------------------------+----------+-------+-----------------------------------+ 52| hash | type | blob | url | 53+--------------------------------------------+----------+-------+-----------------------------------+ 54| "c94450c805876e49b38d2ff1103b8c09cdd2aef4" | "commit" | 00 00 | ...github.com/src-d/flamingo.git" | 55| "7f71640877608ee9cfe584fac216f03f9aebb523" | "commit" | 00 00 | ...github.com/src-d/flamingo.git" | 56| "255f097450dd91812c4eb7b9e0d3a4f034f2acaf" | "commit" | 00 00 | ...github.com/src-d/flamingo.git" | 57+--------------------------------------------+----------+-------+-----------------------------------+ 58102 rows in set (0.071 secs) 59``` 60 61And also the references and the configuration (remotes) are stored in it. 62 63```sql 64aql> SELECT name, target, url FROM test.reference 65``` 66``` 67+------------------------------+--------------------------------------------+-----------------------+ 68| name | target | url | 69+------------------------------+--------------------------------------------+-----------------------+ 70| "HEAD" | "ref: refs/heads/master" | ...rc-d/flamingo.git" | 71| "refs/heads/master" | "ed3e1aa2e46584cb803ed356cb5d8855f6d05660" | ...rc-d/flamingo.git" | 72| "refs/remotes/origin/master" | "ed3e1aa2e46584cb803ed356cb5d8855f6d05660" | ...rc-d/flamingo.git" | 73+------------------------------+--------------------------------------------+-----------------------+ 743 rows in set (0.046 secs) 75``` 76 77### Reading the repository 78 79Running the `log` command, a `git log --online` like result is printed: 80 81```sh 82go-git-aerospike log https://github.com/src-d/flamingo.git 83``` 84 85The URL of the repository is the way we identify the objects in the `set`s, since we can clone several repositories to the same database. 86 87``` 88ed3e1aa ID is also allowed in SendFormTo and SayTo 892031f3e Handle close of message channel in WaitForMessage 90e784495 Add SendFormTo and SayTo 91447748a Make text in attachments accept markdown 92595b4e7 Form author name and author icon and text groupfield 930f2e315 Test for InvokeAction 940dc7c9a Handle closing of channel 95b3f167b Implement InvokeAction 96``` 97 98The process has read all the commits and all the needed objects from the aerospike sets. 99 100### Playing with the database 101 102If you want to explore the database, you can execute the `aql` tool and run some queries: 103 104```sh 105docker run -it aerospike/aerospike-tools aql -h 172.17.0.1 106aql> SELECT * FROM test; 107```