6
6
SELECT refs .repository_id
7
7
FROM refs
8
8
NATURAL JOIN commits
9
- WHERE commits .commit_author_name = ' Javi Fontan' AND refs .ref_name = ' HEAD' ;
9
+ WHERE commits .commit_author_name = ' Javi Fontan' AND refs .ref_name = ' HEAD' ;
10
10
```
11
11
12
12
## Get all the HEAD references from all the repositories
@@ -19,15 +19,15 @@ SELECT * FROM refs WHERE ref_name = 'HEAD';
19
19
20
20
``` sql
21
21
SELECT
22
- file_path,
23
- ref_commits .repository_id
22
+ file_path,
23
+ ref_commits .repository_id
24
24
FROM
25
- commit_files
25
+ commit_files
26
26
NATURAL JOIN
27
- ref_commits
27
+ ref_commits
28
28
WHERE
29
- ref_commits .ref_name = ' HEAD'
30
- AND ref_commits .history_index = 0 ;
29
+ ref_commits .ref_name = ' HEAD'
30
+ AND ref_commits .history_index = 0 ;
31
31
```
32
32
33
33
## Commits that appear in more than one reference
@@ -37,7 +37,7 @@ SELECT * FROM (
37
37
SELECT COUNT (c .commit_hash ) AS num, c .commit_hash
38
38
FROM ref_commits r
39
39
INNER JOIN commits c
40
- ON r .commit_hash = c .commit_hash
40
+ ON r .repository_id = c . repository_id AND r . commit_hash = c .commit_hash
41
41
GROUP BY c .commit_hash
42
42
) t WHERE num > 1 ;
43
43
```
@@ -48,9 +48,11 @@ SELECT * FROM (
48
48
SELECT COUNT (c .commit_hash ), c .commit_hash
49
49
FROM ref_commits as r
50
50
INNER JOIN commits c
51
- ON r .ref_name = ' HEAD' AND r .commit_hash = c .commit_hash
51
+ ON r .ref_name = ' HEAD'
52
+ AND r .repository_id = c .repository_id
53
+ AND r .commit_hash = c .commit_hash
52
54
INNER JOIN commit_blobs cb
53
- ON cb .commit_hash = c .commit_hash
55
+ ON cb .repository_id = c . repository_id AND cb . commit_hash = c .commit_hash
54
56
GROUP BY c .commit_hash ;
55
57
```
56
58
65
67
committer_email
66
68
FROM ref_commits r
67
69
INNER JOIN commits c
68
- ON YEAR(c .committer_when ) = 2015 AND r .commit_hash = c .commit_hash
70
+ ON YEAR(c .committer_when ) = 2015
71
+ AND r .repository_id = c .repository_id
72
+ AND r .commit_hash = c .commit_hash
69
73
WHERE r .ref_name = ' HEAD'
70
74
) as t
71
75
GROUP BY committer_email, month, repo_id;
@@ -75,21 +79,21 @@ GROUP BY committer_email, month, repo_id;
75
79
76
80
``` sql
77
81
select
78
- files .file_path ,
79
- ref_commits .repository_id ,
82
+ files .file_path ,
83
+ ref_commits .repository_id ,
80
84
files .blob_content
81
85
FROM
82
- files
86
+ files
83
87
NATURAL JOIN
84
- commit_files
88
+ commit_files
85
89
NATURAL JOIN
86
- ref_commits
90
+ ref_commits
87
91
WHERE
88
- ref_commits .ref_name = ' HEAD'
89
- AND ref_commits .history_index BETWEEN 0 AND 5
90
- AND is_binary(blob_content) = false
92
+ ref_commits .ref_name = ' HEAD'
93
+ AND ref_commits .history_index BETWEEN 0 AND 5
94
+ AND is_binary(blob_content) = false
91
95
AND files .file_path NOT REGEXP ' ^vendor.*'
92
- AND (
96
+ AND (
93
97
blob_content REGEXP ' (?i)facebook.*[\'\\ "][0-9a-f]{32}[\'\\ "]'
94
98
OR blob_content REGEXP ' (?i)twitter.*[\'\\ "][0-9a-zA-Z]{35,44}[\'\\ "]'
95
99
OR blob_content REGEXP ' (?i)github.*[\'\\ "][0-9a-zA-Z]{35,40}[\'\\ "]'
0 commit comments