From 10f08386f7e0d5af692d9fb8ed0978e4c0ca7af1 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Thu, 15 Apr 2010 15:40:36 +0200 Subject: [PATCH] Fixed to have a simpler code. --- src/IDF/Plugin/SyncGit.php | 6 ++---- src/IDF/Plugin/SyncSvn.php | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/IDF/Plugin/SyncGit.php b/src/IDF/Plugin/SyncGit.php index 41134f4..77bc06f 100644 --- a/src/IDF/Plugin/SyncGit.php +++ b/src/IDF/Plugin/SyncGit.php @@ -65,10 +65,8 @@ class IDF_Plugin_SyncGit */ static public function postUpdate($signal, &$params) { - // Find the corresponding project. - $git_dir = substr($params['git_dir'], 0, -4); // Chop the ".git" - $elts = preg_split('#/#', $git_dir, -1, PREG_SPLIT_NO_EMPTY); - $pname = array_pop($elts); + // Chop the ".git" and get what is left + $pname = basename(substr($params['git_dir'], 0, -4)); try { $project = IDF_Project::getOr404($pname); } catch (Pluf_HTTP_Error404 $e) { diff --git a/src/IDF/Plugin/SyncSvn.php b/src/IDF/Plugin/SyncSvn.php index 1080fa5..bfebf51 100644 --- a/src/IDF/Plugin/SyncSvn.php +++ b/src/IDF/Plugin/SyncSvn.php @@ -242,9 +242,7 @@ class IDF_Plugin_SyncSvn */ public function processSvnUpdateTimeline($params) { - $repo_dir = $params['repo_dir']; - $elts = preg_split('#/#', $repo_dir, -1, PREG_SPLIT_NO_EMPTY); - $pname = array_pop($elts); + $pname = basename($params['repo_dir']); try { $project = IDF_Project::getOr404($pname); } catch (Pluf_HTTP_Error404 $e) {