Skip to content

Commit

Permalink
fix(command): Sort commit message keys consistently
Browse files Browse the repository at this point in the history
- Implement sorting for message keys in the CommitCommand
- Ensure keys are ordered by 'subject', then 'body'
- Added a null entry for empty keys to maintain consistency
- Improves clarity in the output format of commit messages
  • Loading branch information
[email protected] committed Nov 10, 2024
1 parent 9c9a820 commit 5480893
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Commands/CommitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ function ($attempts) use ($cachedDiff, $type): string {
return $content;
})
->tap(function (Collection $message): void {
$message = $message->put('', null)->sortKeysUsing(static function (string $a, string $b): int {
$rules = ['subject', '', 'body'];

return array_search($a, $rules, true) <=> array_search($b, $rules, true);
});
// $this->table($message->keys()->all(), [$message->all()]);
$this->output->horizontalTable($message->keys()->all(), [$message->all()]);
})
Expand Down

0 comments on commit 5480893

Please sign in to comment.