|
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> |
| 1 | +# GitBase <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 | 3 | Query git repositories with a MySQL interface.
|
4 | 4 |
|
@@ -75,39 +75,39 @@ SELECT * FROM refs WHERE name = 'HEAD'
|
75 | 75 |
|
76 | 76 | ```sql
|
77 | 77 | SELECT * FROM (
|
78 |
| - SELECT COUNT(c.hash) AS num, c.hash |
79 |
| - FROM refs r |
80 |
| - INNER JOIN commits c |
81 |
| - ON history_idx(r.hash, c.hash) >= 0 |
82 |
| - GROUP BY c.hash |
83 |
| - ) t WHERE num > 1 |
| 78 | + SELECT COUNT(c.hash) AS num, c.hash |
| 79 | + FROM refs r |
| 80 | + INNER JOIN commits c |
| 81 | + ON history_idx(r.hash, c.hash) >= 0 |
| 82 | + GROUP BY c.hash |
| 83 | +) t WHERE num > 1 |
84 | 84 | ```
|
85 | 85 |
|
86 | 86 | ### Get the number of blobs per HEAD commit
|
87 | 87 | ```sql
|
88 | 88 | SELECT COUNT(c.hash), c.hash
|
89 |
| - FROM refs r |
90 |
| - INNER JOIN commits c |
91 |
| - ON r.name = 'HEAD' AND history_idx(r.hash, c.hash) >= 0 |
92 |
| - INNER JOIN blobs b |
93 |
| - ON commit_has_blob(c.hash, b.hash) |
94 |
| - GROUP BY c.hash |
| 89 | +FROM refs r |
| 90 | +INNER JOIN commits c |
| 91 | + ON r.name = 'HEAD' AND history_idx(r.hash, c.hash) >= 0 |
| 92 | +INNER JOIN blobs b |
| 93 | + ON commit_has_blob(c.hash, b.hash) |
| 94 | +GROUP BY c.hash |
95 | 95 | ```
|
96 | 96 |
|
97 | 97 | ### Get commits per commiter, per month in 2015
|
98 | 98 |
|
99 | 99 | ```sql
|
100 | 100 | SELECT COUNT(*) as num_commits, month, repo_id, committer_email
|
101 |
| - FROM ( |
102 |
| - SELECT |
103 |
| - MONTH(committer_when) as month, |
104 |
| - r.id as repo_id, |
105 |
| - committer_email |
106 |
| - FROM repositories r |
107 |
| - INNER JOIN refs ON refs.repository_id = r.id AND refs.name = 'HEAD' |
108 |
| - INNER JOIN commits c ON YEAR(committer_when) = 2015 AND history_idx(refs.hash, c.hash) >= 0 |
109 |
| - ) as t |
110 |
| - GROUP BY committer_email, month, repo_id |
| 101 | + FROM ( |
| 102 | + SELECT |
| 103 | + MONTH(committer_when) as month, |
| 104 | + r.id as repo_id, |
| 105 | + committer_email |
| 106 | + FROM repositories r |
| 107 | + INNER JOIN refs ON refs.repository_id = r.id AND refs.name = 'HEAD' |
| 108 | + INNER JOIN commits c ON YEAR(committer_when) = 2015 AND history_idx(refs.hash, c.hash) >= 0 |
| 109 | + ) as t |
| 110 | +GROUP BY committer_email, month, repo_id |
111 | 111 | ```
|
112 | 112 |
|
113 | 113 | ## License
|
|
0 commit comments