Skip to content

Commit 75f3399

Browse files
author
ityaozm@gmail.com
committed
perf(commit): Enhance commit command argument handling
- Add a new line before displaying the commit message for better formatting - Refactor the `diffCommand` method to use spread operator for options - Update the `commitCommand` method to also utilize the spread operator for options - These changes improve readability and maintainability of the code
1 parent f7e0bbe commit 75f3399

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

app/Commands/CommitCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function handle(): void
7878
})
7979
->tap(function () use (&$message): void {
8080
$len = str($message)->explode(\PHP_EOL)->map(static fn (string $line): int => mb_strlen($line))->max();
81+
$this->newLine();
8182
$this->line(str_repeat('-', $len));
8283
$this->info($message);
8384
$this->line(str_repeat('-', $len));
@@ -193,8 +194,6 @@ protected function configure(): void
193194
*
194195
* @noinspection MethodVisibilityInspection
195196
* @noinspection PhpMissingParentCallCommonInspection
196-
*
197-
* @throws \JsonException
198197
*/
199198
protected function initialize(InputInterface $input, OutputInterface $output): void
200199
{
@@ -218,7 +217,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
218217

219218
private function diffCommand(): array
220219
{
221-
return array_merge(['git', 'diff', '--cached'], $this->option('diff-options'));
220+
return ['git', 'diff', '--cached', ...$this->option('diff-options')];
222221
}
223222

224223
/**
@@ -231,7 +230,7 @@ private function commitCommandFor(string $message): array
231230
->when($this->shouldntVerify(), static fn (Collection $collection): Collection => $collection->add('--no-verify'))
232231
->all();
233232

234-
return array_merge(['git', 'commit', '--message', $message], $options);
233+
return ['git', 'commit', '--message', $message, ...$options];
235234
}
236235

237236
private function promptFor(string $cachedDiff, string $type): string

0 commit comments

Comments
 (0)