Skip to content

Commit

Permalink
fix(commands): Fix formatting issue in CommitCommand
Browse files Browse the repository at this point in the history
- Fix formatting issue in the CommitCommand file
- Transform body lines to start with a hyphen
- Set process timeout to null
- Set process to must run
  • Loading branch information
ityaozm@gmail.com committed Jan 3, 2024
1 parent 04d27f9 commit b7a01f3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/Commands/CommitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ function ($attempts) use ($cachedDiff): string {
);
}, 'generating...'.PHP_EOL);

$this->task(str_repeat(PHP_EOL, 2).'2. Confirming commit message', function () use (&$message): void {
$this->task(PHP_EOL.'2. Confirming commit message', function () use (&$message): void {
$message = collect(json_decode($message, true, 512, JSON_THROW_ON_ERROR))
->pipe(static function (Collection $message): Collection {
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);
})
->implode(PHP_EOL);
}

return $message;
Expand All @@ -125,10 +126,10 @@ function ($attempts) use ($cachedDiff): string {
});
}, 'confirming...'.PHP_EOL);

$this->task(str_repeat(PHP_EOL, 2).'3. Committing message', function () use ($message): void {
$this->task(PHP_EOL.'3. Committing message', function () use ($message): void {
tap($this->createProcess($this->getCommitCommand($message)), function (Process $process): void {
$this->shouldEdit() and $process->setTty(true);
})->setTimeout(null)->run();
})->setTimeout(null)->mustRun();
}, 'committing...'.PHP_EOL);

$this->output->success('Successfully generated and committed message.');
Expand Down

0 comments on commit b7a01f3

Please sign in to comment.