@@ -26,9 +26,9 @@ SELECT * FROM refs WHERE ref_name = 'HEAD'
26
26
``` sql
27
27
SELECT * FROM (
28
28
SELECT COUNT (c .commit_hash ) AS num, c .commit_hash
29
- FROM refs r
29
+ FROM ref_commits r
30
30
INNER JOIN commits c
31
- ON history_idx( r .commit_hash , c .commit_hash ) >= 0
31
+ ON r .commit_hash = c .commit_hash
32
32
GROUP BY c .commit_hash
33
33
) t WHERE num > 1
34
34
```
@@ -37,11 +37,11 @@ SELECT * FROM (
37
37
38
38
``` sql
39
39
SELECT COUNT (c .commit_hash ), c .commit_hash
40
- FROM refs r
40
+ FROM ref_commitss r
41
41
INNER JOIN commits c
42
- ON r .ref_name = ' HEAD' AND history_idx( r .commit_hash , c .commit_hash ) >= 0
43
- INNER JOIN blobs b
44
- ON commit_has_blob( c .commit_hash , b .commit_hash )
42
+ ON r .ref_name = ' HEAD' AND r .commit_hash = c .commit_hash
43
+ INNER JOIN commit_blobs cb
44
+ ON cb .commit_hash = c .commit_hash
45
45
GROUP BY c .commit_hash
46
46
```
47
47
@@ -54,11 +54,10 @@ FROM (
54
54
MONTH(committer_when) as month,
55
55
r .repository_id as repo_id,
56
56
committer_email
57
- FROM repositories r
58
- INNER JOIN refs
59
- ON refs .repository_id = r .repository_id AND refs .ref_name = ' HEAD'
60
- INNER JOIN commits c
61
- ON YEAR(committer_when) = 2015 AND history_idx(refs .commit_hash , c .commit_hash ) >= 0
57
+ FROM ref_commits r
58
+ INNER JOIN commits c
59
+ ON YEAR(c .committer_when ) = 2015 AND r .commit_hash = c .commit_hash
60
+ WHERE r .ref_name = ' HEAD'
62
61
) as t
63
62
GROUP BY committer_email, month, repo_id
64
63
```
@@ -136,22 +135,21 @@ gitbase exposes the following tables:
136
135
| repositories | repository_id |
137
136
| remotes | repository_id, remote_name, remote_push_url, remote_fetch_url, remote_push_refspec, remote_fetch_refspec |
138
137
| commits | repository_id, commit_hash, commit_author_name, commit_author_email, commit_author_when, committer_name, committer_email, committer_when, commit_message, tree_hash |
139
- | blobs | repository_id, blob_hash, blob_size, blob_content |
140
- | refs | repository_id, ref_name, commit_hash |
141
- | tree_entries | repository_id, tree_hash, blob_hash, tree_entry_mode, tree_entry_name |
142
- | references | repository_id, ref_name, commit_hash |
143
- | ref_commits | repository_id, commit_hash, ref_name, index |
144
- | commit_trees | repository_id, commit_hash, tree_hash |
138
+ | blobs | repository_id, blob_hash, blob_size, blob_content |
139
+ | refs | repository_id, ref_name, commit_hash |
140
+ | ref_commits | repository_id, ref_name, commit_hash, index |
141
+ | tree_entries | repository_id, tree_hash, blob_hash, tree_entry_mode, tree_entry_name |
142
+ | references | repository_id, ref_name, commit_hash |
143
+ | commit_trees | repository_id, commit_hash, tree_hash |
144
+ | commit_blobs | repository_id, commit_hash, blob_hash |
145
+ | files | repository_id, file_path, blob_hash, tree_hash, tree_entry_mode, blob_content, blob_size |
145
146
146
147
## Functions
147
148
148
149
To make some common tasks easier for the user, there are some functions to interact with the previous mentioned tables:
149
150
150
151
| Name | Description |
151
152
| :-------------| :----------------------------------------------------------------------------------------------------|
152
- | commit_has_blob(commit_hash,blob_hash)bool| get if the specified commit contains the specified blob |
153
- | commit_has_tree(commit_hash,tree_hash)bool| get if the specified commit contains the specified tree |
154
- | history_idx(start_hash, target_hash)int| get the index of a commit in the history of another commit |
155
153
| is_remote(reference_name)bool| check if the given reference name is from a remote one |
156
154
| is_tag(reference_name)bool| check if the given reference name is a tag |
157
155
| language(path, [ blob] )text| gets the language of a file given its path and the optional content of the file |
0 commit comments