Skip to content

Commit

Permalink
fix(robo): prevent exception when computong log with commit without body
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 e8814f3 commit e5aa246
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,6 @@ public static function getFileFromGit($path, $rev) {

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

Expand Down Expand Up @@ -825,10 +822,10 @@ public static function compareCommits($a, $b) {
return 1;
}

// then compare message
if ($a->message < $b->message) {
// then compare subject
if ($a->subject < $b->subject) {
return -1;
} else if ($a->message > $b->message) {
} else if ($a->subject > $b->subject) {
return 1;
}

Expand Down Expand Up @@ -977,7 +974,7 @@ public static function buildLogLine($commit, $remote) {
}
$hash = $commit->hash;
$line .= " $commit->subject"
. "([$hash]($remote/commit/$hash))";
. " ([$hash]($remote/commit/$hash))";

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

0 comments on commit e5aa246

Please sign in to comment.