Skip to content

Commit

Permalink
Added in the repository as part of the SHA1 match
Browse files Browse the repository at this point in the history
Duh, we have several repositories, SHA1 can be repeated in other repos.
  • Loading branch information
Beirdo committed Feb 27, 2011
1 parent b25e4fd commit 8d98e8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions git_hooks/email_hook.pl
Expand Up @@ -55,10 +55,10 @@
$config{'db'}{'user'}, $config{'db'}{'password'})
or die "Cannot connect to database: " . DBI::errstr . "\n";
my $q = "SELECT sha1 FROM seen WHERE sha1 = ?";
my $q = "SELECT sha1 FROM seen WHERE repo = ?, sha1 = ?";
my $select_h = $dbh->prepare($q);
$q = "INSERT INTO seen (sha1, lastseen) VALUES (?, NULL)";
$q = "INSERT INTO seen (repo, sha1, lastseen) VALUES (?, ?, NULL)";
my $insert_h = $dbh->prepare($q);
Expand All @@ -73,7 +73,7 @@
foreach my $commit ( @{$payload->{"commits"}} ) {
my $longsha = $commit->{"id"};
$select_h->execute($longsha);
$select_h->execute($repository,$longsha);
my ($resultsha) = $select_h->fetchrow_array;
next if defined $resultsha;
Expand Down Expand Up @@ -131,6 +131,6 @@
print $fh $email;
$fh->close;
$insert_h->execute($longsha);
$insert_h->execute($repository,$longsha);
}
3 changes: 2 additions & 1 deletion git_hooks/email_hook.sql
Expand Up @@ -2,7 +2,8 @@ create database email_hook;
grant all privileges on email_hook.* to email_hook@localhost identified by "email_hook";
use email_hook;
CREATE TABLE `seen` (
`repo` VARCHAR( 40 ) NOT NULL ,
`sha1` VARCHAR( 40 ) NOT NULL ,
`lastseen` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `sha1` )
PRIMARY KEY ( `repo`, `sha1` )
);

0 comments on commit 8d98e8a

Please sign in to comment.