Skip to content

Commit ff604ee

Browse files
committed
fix(build): invert order of versions in changelog
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent e5aa246 commit ff604ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

RoboFile.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,15 @@ public static function buildLog($a, $b = 'HEAD') {
873873
return true;
874874
});
875875

876-
// sort tags
876+
// sort tags older DESCENDING
877877
usort($tags, function ($a, $b) {
878-
return version_compare($a, $b);
878+
return version_compare($b, $a);
879879
});
880880

881881
$log = [];
882-
$tags[] = $b;
882+
if ($b === '"Unreleaased') {
883+
array_unshift($tags, $b);
884+
}
883885
$startRef = array_shift($tags);
884886
while ($endRef = array_shift($tags)) {
885887
$log = array_merge($log, self::buildLogOneBump($startRef, $endRef));
@@ -903,7 +905,7 @@ public static function buildLogOneBump($a, $b) {
903905
$remote = $remotes['origin'];
904906

905907
// Get all commits from A to B
906-
$commits = Git::createCommitList(Git::getLog($a, $b));
908+
$commits = Git::createCommitList(Git::getLog($b, $a));
907909

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

932934
$tagDate = (new DateTime())->format('Y-m-d');
933-
$compare = "$remote/compare/$a..";
935+
$compare = "$remote/compare/";
934936
if ($tag !== 'Unreleased') {
935937
$tagDate = Git::getTagDate($tag)->format('Y-m-d');
936938
$compare .= $tag;
937939
} else {
938940
$compare .= Git::getCurrentBranch();
939941
}
942+
$compare .= "..$a";
940943
$log[] = '<a name="' . $tag . '"></a>';
941944
$log[] = '## [' . $tag . '](' . $compare . ') (' . $tagDate . ')';
942945
$log[] = '';

0 commit comments

Comments
 (0)