From 28ce82c6f6d066065edf216d9385fc811669e7d5 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Tue, 11 May 2010 09:41:22 +0200 Subject: [PATCH] Improved to sort the Git tags by reverse chronological order. --- src/IDF/Scm/Git.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php index cd7ec0f..5a9c2ee 100644 --- a/src/IDF/Scm/Git.php +++ b/src/IDF/Scm/Git.php @@ -125,7 +125,7 @@ class IDF_Scm_Git extends IDF_Scm return $this->cache['tags']; } $cmd = Pluf::f('idf_exec_cmd_prefix', '') - .sprintf('GIT_DIR=%s %s tag', + .sprintf('GIT_DIR=%s %s for-each-ref --format="%%(taggerdate:iso)%%(committerdate:iso) %%(objectname) %%(refname)" refs/tags', escapeshellarg($this->repo), Pluf::f('git_path', 'git')); self::exec('IDF_Scm_Git::getTags', $cmd, $out, $return); @@ -134,12 +134,15 @@ class IDF_Scm_Git extends IDF_Scm $cmd, $return, implode("\n", $out))); } + rsort($out); $res = array(); foreach ($out as $b) { - if (false !== strpos($b, '/')) { - $res[$this->getCommit($b)->commit] = $b; + $elts = explode(' ', $b, 5); + $tag = substr(trim($elts[4]), 10); + if (false !== strpos($tag, '/')) { + $res[$elts[3]] = $b; } else { - $res[$b] = ''; + $res[$tag] = ''; } } $this->cache['tags'] = $res;