Skip to content

Commit

Permalink
chore(commands): update CommitCommand.php
Browse files Browse the repository at this point in the history
- Add use Illuminate\Support\Str
- Transform array body lines to bullet points
  • Loading branch information
ityaozm@gmail.com committed Nov 16, 2023
1 parent da1ad65 commit 7fe46c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Commands/CommitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Support\JsonFixer;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use LaravelZero\Framework\Commands\Command;
use Symfony\Component\Console\Completion\CompletionInput;
Expand Down Expand Up @@ -103,6 +104,16 @@ function ($attempts) use ($cachedDiff): string {

$this->task('2. Choosing commit message', function () use (&$message, $messages): void {
$message = collect(json_decode($messages, true, 512, JSON_THROW_ON_ERROR))
->transform(function (array $message): array {
if (\is_array($message['body'])) {
$message['body'] = collect($message['body'])
->transform(static function (string $line): string {
return Str::start(trim($line, " \t\n\r\x0B"), '- ');
})->implode(PHP_EOL);
}

return $message;
})
->tap(function (Collection $messages): void {
$this->newLine(2);
$this->table(
Expand Down

0 comments on commit 7fe46c5

Please sign in to comment.