Skip to content

Commit e5aa246

Browse files
committed
fix(robo): prevent exception when computong log with commit without body
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent e8814f3 commit e5aa246

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

RoboFile.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,6 @@ public static function getFileFromGit($path, $rev) {
771771

772772
public static function getCommitBody($hash) {
773773
$output = shell_exec("git log $hash --max-count=1 --pretty=format:\"%b\"");
774-
if ($output === null) {
775-
throw new Exception ("could not get commit body");
776-
}
777774
return $output;
778775
}
779776

@@ -825,10 +822,10 @@ public static function compareCommits($a, $b) {
825822
return 1;
826823
}
827824

828-
// then compare message
829-
if ($a->message < $b->message) {
825+
// then compare subject
826+
if ($a->subject < $b->subject) {
830827
return -1;
831-
} else if ($a->message > $b->message) {
828+
} else if ($a->subject > $b->subject) {
832829
return 1;
833830
}
834831

@@ -977,7 +974,7 @@ public static function buildLogLine($commit, $remote) {
977974
}
978975
$hash = $commit->hash;
979976
$line .= " $commit->subject"
980-
. "([$hash]($remote/commit/$hash))";
977+
. " ([$hash]($remote/commit/$hash))";
981978

982979
// Search for closed issues
983980
$body = explode(PHP_EOL, $commit->body);

0 commit comments

Comments
 (0)