1
1
# GitQuery <a href =" https://travis-ci.org/src-d/gitquery " ><img alt =" Build Status " src =" https://travis-ci.org/src-d/gitquery.svg?branch=master " /></a > <a href =" https://codecov.io/gh/src-d/gitquery " ><img alt =" codecov " src =" https://codecov.io/gh/src-d/gitquery/branch/master/graph/badge.svg " /></a > <a href =" https://godoc.org/gopkg.in/src-d/gitquery.v0 " ><img alt =" GoDoc " src =" https://godoc.org/gopkg.in/src-d/gitquery.v0?status.svg " /></a >
2
2
3
- See a set of repositories as a standard database .
3
+ Query git repositories with a MySQL interface .
4
4
5
5
## Installation
6
6
@@ -58,6 +58,7 @@ To make some common tasks easier for the user, there are some functions to inter
58
58
| Name | Description |
59
59
| :------------:| :---------------------------------------------------------------------------------------------------:|
60
60
| commit_has_blob(commit_hash,blob_hash)bool| get if the specified commit contains the specified blob |
61
+ | commit_has_tree(commit_hash,tree_hash)bool| get if the specified commit contains the specified tree |
61
62
| history_idx(start_hash, target_hash)int| get the index of a commit in the history of another commit |
62
63
| is_remote(reference_name)bool| check if the given reference name is from a remote one |
63
64
| is_tag(reference_name)bool| check if the given reference name is a tag |
@@ -87,10 +88,9 @@ SELECT * FROM (
87
88
SELECT COUNT (c .hash ), c .hash
88
89
FROM refs r
89
90
INNER JOIN commits c
90
- ON history_idx(r .hash , c .hash ) >= 0
91
+ ON r . name = ' HEAD ' AND history_idx(r .hash , c .hash ) >= 0
91
92
INNER JOIN blobs b
92
93
ON commit_has_blob(c .hash , b .hash )
93
- WHERE r .name = ' HEAD'
94
94
GROUP BY c .hash
95
95
```
96
96
@@ -105,8 +105,7 @@ SELECT COUNT(*) as num_commits, month, repo_id, committer_email
105
105
committer_email
106
106
FROM repositories r
107
107
INNER JOIN refs ON refs .repository_id = r .id AND refs .name = ' HEAD'
108
- INNER JOIN commits c ON history_idx(refs .hash , c .hash ) >= 0
109
- WHERE YEAR(committer_when) = 2015
108
+ INNER JOIN commits c ON YEAR(committer_when) = 2015 AND history_idx(refs .hash , c .hash ) >= 0
110
109
) as t
111
110
GROUP BY committer_email, month, repo_id
112
111
```
0 commit comments