Skip to content

Commit

Permalink
fix(build): invert order of versions in changelog
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jan 14, 2020
1 parent 876a9d0 commit 9a8782e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,15 @@ public static function buildLog($a, $b = 'HEAD') {
return true;
});

// sort tags
// sort tags older DESCENDING
usort($tags, function ($a, $b) {
return version_compare($a, $b);
return version_compare($b, $a);
});

$log = [];
$tags[] = $b;
if ($b === '"Unreleaased') {
array_unshift($tags, $b);
}
$startRef = array_shift($tags);
while ($endRef = array_shift($tags)) {
$log = array_merge($log, self::buildLogOneBump($startRef, $endRef));
Expand All @@ -903,7 +905,7 @@ public static function buildLogOneBump($a, $b) {
$remote = $remotes['origin'];

// Get all commits from A to B
$commits = Git::createCommitList(Git::getLog($a, $b));
$commits = Git::createCommitList(Git::getLog($b, $a));

// Remove non conventional commits
$commits = self::filterCommits($commits);
Expand All @@ -930,13 +932,14 @@ public static function buildLogOneBump($a, $b) {
$log = [];

$tagDate = (new DateTime())->format('Y-m-d');
$compare = "$remote/compare/$a..";
$compare = "$remote/compare/";
if ($tag !== 'Unreleased') {
$tagDate = Git::getTagDate($tag)->format('Y-m-d');
$compare .= $tag;
} else {
$compare .= Git::getCurrentBranch();
}
$compare .= "..$a";
$log[] = '<a name="' . $tag . '"></a>';
$log[] = '## [' . $tag . '](' . $compare . ') (' . $tagDate . ')';
$log[] = '';
Expand Down

0 comments on commit 9a8782e

Please sign in to comment.