Skip to content

Commit

Permalink
feat(CommitCommand.php): Modify commit type selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ityaozm@gmail.com committed Jun 11, 2024
1 parent 66d7f2c commit 200a78b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/Commands/CommitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ public function handle(): int
throw new TaskException('There are no cached files to commit. Try running `git add` to cache some files.');
}

$type = $this->choice('Please choice commit type', $types = $this->configManager->get('types'), array_key_first($types));
$type = $this->choice(
'Please choice commit type',
$types = $this->configManager->get('types'),
array_key_first($types)
);

$message = retry(
$this->option('retry-times'),
Expand Down Expand Up @@ -287,9 +291,10 @@ private function getDiffCommand(): array
private function getPrompt(string $cachedDiff, string $type): string
{
$typePrompt = sprintf($this->configManager->get('type_prompt'), $type);

if (array_key_first($this->configManager->get('types')) === $type) {
$type = $this->configManager->get('type_mark');
$typePrompt = '';
$type = $this->configManager->get('type_mark'); // Reset type.
$typePrompt = ''; // Clear type prompt.
}

return (string) str($this->configManager->get("prompts.{$this->option('prompt')}"))
Expand Down

0 comments on commit 200a78b

Please sign in to comment.