From 38e6e4f8d390cec241a66186bd6f48f29fa29007 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Wed, 9 Feb 2011 16:35:50 +0100 Subject: [PATCH] Use all registered email addresses to map Scm users to IDF users. --- src/IDF/Scm/Git.php | 12 +++++------- src/IDF/Scm/Mercurial.php | 4 +--- src/IDF/Scm/Monotone.php | 12 +++++------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index e8ac2f6..6c00c5d 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -271,14 +271,12 @@ class IDF_Scm_Git extends IDF_Scm if (!preg_match('/<(.*)>/', $author, $match)) { return null; } - foreach (array('email', 'login') as $what) { - $sql = new Pluf_SQL($what.'=%s', array($match[1])); - $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); - if ($users->count() > 0) { - return $users[0]; - } + $sql = new Pluf_SQL('login=%s', array($match[1])); + $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); + if ($users->count() > 0) { + return $users[0]; } - return null; + return Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($match[1]); } public static function getAnonymousAccessUrl($project, $commit=null) diff --git a/src/IDF/Scm/Mercurial.php b/src/IDF/Scm/Mercurial.php index b52e9f9..a413cb1 100644 --- a/src/IDF/Scm/Mercurial.php +++ b/src/IDF/Scm/Mercurial.php @@ -67,9 +67,7 @@ class IDF_Scm_Mercurial extends IDF_Scm if (!preg_match('/<(.*)>/', $author, $match)) { return null; } - $sql = new Pluf_SQL('email=%s', array($match[1])); - $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); - return ($users->count() > 0) ? $users[0] : null; + return Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($match[1]); } public function getMainBranch() diff --git a/src/IDF/Scm/Monotone.php b/src/IDF/Scm/Monotone.php index b47dfd0..5ec5bfa 100644 --- a/src/IDF/Scm/Monotone.php +++ b/src/IDF/Scm/Monotone.php @@ -400,14 +400,12 @@ class IDF_Scm_Monotone extends IDF_Scm if (!preg_match('/([^ ]+@[^ ]+)/', $author, $match)) { return null; } - foreach (array('email', 'login') as $what) { - $sql = new Pluf_SQL($what.'=%s', array($match[1])); - $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); - if ($users->count() > 0) { - return $users[0]; - } + $sql = new Pluf_SQL('login=%s', array($match[1])); + $users = Pluf::factory('Pluf_User')->getList(array('filter'=>$sql->gen())); + if ($users->count() > 0) { + return $users[0]; } - return null; + return Pluf::factory('IDF_EmailAddress')->get_user_for_email_address($match[1]); } /**