Skip to content

Commit 0598cf3

Browse files
committed
readme: some improvements
Signed-off-by: Máximo Cuadros <[email protected]>
1 parent 541f15c commit 0598cf3

File tree

1 file changed

+67
-49
lines changed

1 file changed

+67
-49
lines changed

README.md

Lines changed: 67 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,73 @@
1-
# gitbase <a href="https://travis-ci.org/src-d/gitbase"><img alt="Build Status" src="https://travis-ci.org/src-d/gitbase.svg?branch=master" /></a> <a href="https://codecov.io/gh/src-d/gitbase"><img alt="codecov" src="https://codecov.io/gh/src-d/gitbase/branch/master/graph/badge.svg" /></a> <a href="https://godoc.org/gopkg.in/src-d/gitbase.v0"><img alt="GoDoc" src="https://godoc.org/gopkg.in/src-d/gitbase.v0?status.svg" /></a>
1+
# gitbase [![GitHub version](https://badge.fury.io/gh/src-d%2Fgitbase.svg)](https://github.com/mcuadros/ofelia/releases) [![Build Status](https://travis-ci.org/src-d/gitbase.svg?branch=master)](https://travis-ci.org/src-d/gitbase) [![codecov](https://codecov.io/gh/src-d/gitbase/branch/master/graph/badge.svg)](https://codecov.io/gh/src-d/gitbase) [![GoDoc](https://godoc.org/gopkg.in/src-d/gitbase.v0?status.svg)](https://godoc.org/gopkg.in/src-d/gitbase.v0) [![Go Report Card](https://goreportcard.com/badge/github.com/src-d/gitbase)](https://goreportcard.com/report/github.com/src-d/gitbase)
22

3-
Query git repositories with a MySQL interface.
3+
**gitbase**, is a database interface to git repository.
4+
5+
It can be used to perform SQL queries about the git history but as well about
6+
the code itself through the AST, on top or any number of git repository.
7+
8+
gitbase implements the *MySQL* wire protocol, it can be accessed using any MySQL
9+
client or library from any language.
10+
11+
## Status
12+
13+
The project is currently in **alpha** stage, not being performance in many of the
14+
cases, but we are working hard on getting a performance system able to processes
15+
thousands of repositories in a single node. Stay tuned!
16+
17+
## Examples
18+
19+
#### Get all the HEAD references from all the repositories
20+
21+
```sql
22+
SELECT * FROM refs WHERE ref_name = 'HEAD'
23+
```
24+
25+
#### Commits that appears in more than one reference
26+
27+
```sql
28+
SELECT * FROM (
29+
SELECT COUNT(c.commit_hash) AS num, c.commit_hash
30+
FROM refs r
31+
INNER JOIN commits c
32+
ON history_idx(r.commit_hash, c.commit_hash) >= 0
33+
GROUP BY c.commit_hash
34+
) t WHERE num > 1
35+
```
36+
37+
#### Get the number of blobs per HEAD commit
38+
39+
```sql
40+
SELECT COUNT(c.commit_hash), c.commit_hash
41+
FROM refs r
42+
INNER JOIN commits c
43+
ON r.ref_name = 'HEAD' AND history_idx(r.commit_hash, c.commit_hash) >= 0
44+
INNER JOIN blobs b
45+
ON commit_has_blob(c.commit_hash, b.commit_hash)
46+
GROUP BY c.commit_hash
47+
```
48+
49+
#### Get commits per commiter, per month in 2015
50+
51+
```sql
52+
SELECT COUNT(*) as num_commits, month, repo_id, committer_email
53+
FROM (
54+
SELECT
55+
MONTH(committer_when) as month,
56+
r.repository_id as repo_id,
57+
committer_email
58+
FROM repositories r
59+
INNER JOIN refs
60+
ON refs.repository_id = r.repository_id AND refs.ref_name = 'HEAD'
61+
INNER JOIN commits c
62+
ON YEAR(committer_when) = 2015 AND history_idx(refs.commit_hash, c.commit_hash) >= 0
63+
) as t
64+
GROUP BY committer_email, month, repo_id
65+
```
466

567
## Installation
668

69+
### Installing from binaries
70+
771
Check the [Releases](https://github.com/src-d/gitbase/releases) page to download the gitbase binary.
872

973
### Installing from source
@@ -97,52 +161,6 @@ To make some common tasks easier for the user, there are some functions to inter
97161

98162
- **Table squashing:** there is an optimization that collects inner joins between tables with a set of supported conditions and converts them into a single node that retrieves the data in chained steps (getting first the commits and then the blobs of every commit instead of joinin all commits and all blobs, for example). It can be enabled with the environment variable `GITBASE_UNSTABLE_SQUASH_ENABLE`.
99163

100-
## Examples
101-
102-
### Get all the HEAD references from all the repositories
103-
```sql
104-
SELECT * FROM refs WHERE ref_name = 'HEAD'
105-
```
106-
107-
### Commits that appears in more than one reference
108-
109-
```sql
110-
SELECT * FROM (
111-
SELECT COUNT(c.commit_hash) AS num, c.commit_hash
112-
FROM refs r
113-
INNER JOIN commits c
114-
ON history_idx(r.commit_hash, c.commit_hash) >= 0
115-
GROUP BY c.commit_hash
116-
) t WHERE num > 1
117-
```
118-
119-
### Get the number of blobs per HEAD commit
120-
```sql
121-
SELECT COUNT(c.commit_hash), c.commit_hash
122-
FROM refs r
123-
INNER JOIN commits c
124-
ON r.ref_name = 'HEAD' AND history_idx(r.commit_hash, c.commit_hash) >= 0
125-
INNER JOIN blobs b
126-
ON commit_has_blob(c.commit_hash, b.commit_hash)
127-
GROUP BY c.commit_hash
128-
```
129-
130-
### Get commits per commiter, per month in 2015
131-
132-
```sql
133-
SELECT COUNT(*) as num_commits, month, repo_id, committer_email
134-
FROM (
135-
SELECT
136-
MONTH(committer_when) as month,
137-
r.repository_id as repo_id,
138-
committer_email
139-
FROM repositories r
140-
INNER JOIN refs ON refs.repository_id = r.repository_id AND refs.ref_name = 'HEAD'
141-
INNER JOIN commits c ON YEAR(committer_when) = 2015 AND history_idx(refs.commit_hash, c.commit_hash) >= 0
142-
) as t
143-
GROUP BY committer_email, month, repo_id
144-
```
145-
146164
## License
147165

148-
gitbase is licensed under the [Apache 2.0 License](/LICENSE).
166+
Apache License Version 2.0, see [LICENSE](LICENSE)

0 commit comments

Comments
 (0)