Improved to sort the Git tags by reverse chronological order.

This commit is contained in:
Loic d'Anterroches 2010-05-11 09:41:22 +02:00
parent 641a3b24a5
commit 28ce82c6f6

View File

@ -125,7 +125,7 @@ class IDF_Scm_Git extends IDF_Scm
return $this->cache['tags']; return $this->cache['tags'];
} }
$cmd = Pluf::f('idf_exec_cmd_prefix', '') $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), escapeshellarg($this->repo),
Pluf::f('git_path', 'git')); Pluf::f('git_path', 'git'));
self::exec('IDF_Scm_Git::getTags', $cmd, $out, $return); self::exec('IDF_Scm_Git::getTags', $cmd, $out, $return);
@ -134,12 +134,15 @@ class IDF_Scm_Git extends IDF_Scm
$cmd, $return, $cmd, $return,
implode("\n", $out))); implode("\n", $out)));
} }
rsort($out);
$res = array(); $res = array();
foreach ($out as $b) { foreach ($out as $b) {
if (false !== strpos($b, '/')) { $elts = explode(' ', $b, 5);
$res[$this->getCommit($b)->commit] = $b; $tag = substr(trim($elts[4]), 10);
if (false !== strpos($tag, '/')) {
$res[$elts[3]] = $b;
} else { } else {
$res[$b] = ''; $res[$tag] = '';
} }
} }
$this->cache['tags'] = $res; $this->cache['tags'] = $res;