From 93c44feb052aef972713c3ee1f8ae3f8500b98d8 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Thu, 27 Nov 2008 09:30:12 +0100 Subject: [PATCH] Fixed issue 61, better sync of the source changelog with the latest updates. The sync is made automatically on all the branches of the project when looking at the timeline after a given time. --- src/IDF/Scm.php | 20 ++++++++++++++++++++ src/IDF/Views/Project.php | 1 + 2 files changed, 21 insertions(+) diff --git a/src/IDF/Scm.php b/src/IDF/Scm.php index 8ee8c28..1a3249f 100644 --- a/src/IDF/Scm.php +++ b/src/IDF/Scm.php @@ -81,5 +81,25 @@ class IDF_Scm } return $res; } + + /** + * Sync the changes in the repository with the timeline. + * + */ + public static function syncTimeline($request) + { + $cache = Pluf_Cache::factory(); + $key = 'IDF_Scm:'.$request->project->shortname.':lastsync'; + if (null === ($res=$cache->get($key))) { + $scm = IDF_Scm::get($request); + foreach ($scm->getBranches() as $branche) { + foreach ($scm->getChangeLog($branche, 25) as $change) { + IDF_Commit::getOrAdd($change, $request->project); + } + } + $cache->set($key, true, (int)(Pluf::f('cache_timeout', 300)/2)); + } + } + } diff --git a/src/IDF/Views/Project.php b/src/IDF/Views/Project.php index 53f0c3e..5c64ed5 100644 --- a/src/IDF/Views/Project.php +++ b/src/IDF/Views/Project.php @@ -79,6 +79,7 @@ class IDF_Views_Project $rights = array(); if (true === IDF_Precondition::accessSource($request)) { $rights[] = '\'IDF_Commit\''; + IDF_Scm::syncTimeline($request); } if (true === IDF_Precondition::accessIssues($request)) { $rights[] = '\'IDF_Issue\'';