Skip to content

Commit 8d98e8a

Browse files
committed
Added in the repository as part of the SHA1 match
Duh, we have several repositories, SHA1 can be repeated in other repos.
1 parent b25e4fd commit 8d98e8a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

git_hooks/email_hook.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
$config{'db'}{'user'}, $config{'db'}{'password'})
5656
or die "Cannot connect to database: " . DBI::errstr . "\n";
5757
58-
my $q = "SELECT sha1 FROM seen WHERE sha1 = ?";
58+
my $q = "SELECT sha1 FROM seen WHERE repo = ?, sha1 = ?";
5959
my $select_h = $dbh->prepare($q);
6060
61-
$q = "INSERT INTO seen (sha1, lastseen) VALUES (?, NULL)";
61+
$q = "INSERT INTO seen (repo, sha1, lastseen) VALUES (?, ?, NULL)";
6262
my $insert_h = $dbh->prepare($q);
6363
6464
@@ -73,7 +73,7 @@
7373
7474
foreach my $commit ( @{$payload->{"commits"}} ) {
7575
my $longsha = $commit->{"id"};
76-
$select_h->execute($longsha);
76+
$select_h->execute($repository,$longsha);
7777
my ($resultsha) = $select_h->fetchrow_array;
7878
next if defined $resultsha;
7979
@@ -131,6 +131,6 @@
131131
print $fh $email;
132132
$fh->close;
133133
134-
$insert_h->execute($longsha);
134+
$insert_h->execute($repository,$longsha);
135135
}
136136

git_hooks/email_hook.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ create database email_hook;
22
grant all privileges on email_hook.* to email_hook@localhost identified by "email_hook";
33
use email_hook;
44
CREATE TABLE `seen` (
5+
`repo` VARCHAR( 40 ) NOT NULL ,
56
`sha1` VARCHAR( 40 ) NOT NULL ,
67
`lastseen` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
7-
PRIMARY KEY ( `sha1` )
8+
PRIMARY KEY ( `repo`, `sha1` )
89
);

0 commit comments

Comments
 (0)