From 8d98e8ad7c44357def9c2f06b79b0d8710056ebc Mon Sep 17 00:00:00 2001 From: Gavin Hurlbut Date: Sat, 26 Feb 2011 21:59:02 -0800 Subject: [PATCH] Added in the repository as part of the SHA1 match Duh, we have several repositories, SHA1 can be repeated in other repos. --- git_hooks/email_hook.pl | 8 ++++---- git_hooks/email_hook.sql | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/git_hooks/email_hook.pl b/git_hooks/email_hook.pl index e7ae987..8689c07 100755 --- a/git_hooks/email_hook.pl +++ b/git_hooks/email_hook.pl @@ -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); @@ -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; @@ -131,6 +131,6 @@ print $fh $email; $fh->close; - $insert_h->execute($longsha); + $insert_h->execute($repository,$longsha); } diff --git a/git_hooks/email_hook.sql b/git_hooks/email_hook.sql index 52239be..4f11d11 100644 --- a/git_hooks/email_hook.sql +++ b/git_hooks/email_hook.sql @@ -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` ) );