Skip to content

Commit 00f6af2

Browse files
nezaboravigithub-actions[bot]
authored andcommitted
Fix styling
1 parent e60dd00 commit 00f6af2

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/Commands/CommitvelCommand.php

+26-24
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Console\Command;
66
use Laravel\Prompts\Concerns\Colors;
77
use Symfony\Component\Process\Process;
8+
89
use function Laravel\Prompts\confirm;
910
use function Laravel\Prompts\multiSelect;
1011
use function Laravel\Prompts\spin;
@@ -15,11 +16,12 @@ class CommitvelCommand extends Command
1516
use Colors;
1617

1718
protected $signature = 'cw:commitvel';
19+
1820
protected $description = 'Like a pre-commit hook for running Pint, PHPPest, and managing Git operations written with laravel prompt';
1921

2022
public function handle(): void
2123
{
22-
if (!$this->hasChanges()) {
24+
if (! $this->hasChanges()) {
2325
$this->tellJokeAndExit();
2426
}
2527

@@ -34,25 +36,26 @@ public function handle(): void
3436
protected function hasChanges(): bool
3537
{
3638
$changes = shell_exec('git status --porcelain');
37-
$statusMessage = "Initial git status changes: \n" . $this->formatGitStatus($changes);
39+
$statusMessage = "Initial git status changes: \n".$this->formatGitStatus($changes);
3840

3941
if (preg_match('/^\?\?/', $changes)) {
4042
$this->info($this->red($statusMessage));
4143
} else {
4244
$this->info($statusMessage);
4345
}
4446

45-
return !empty(trim($changes));
47+
return ! empty(trim($changes));
4648
}
4749

4850
protected function formatGitStatus(string $status): string
4951
{
5052
$lines = array_filter(explode("\n", $status));
5153
foreach ($lines as &$line) {
5254
if (str_starts_with(trim($line), '??')) {
53-
$line = $this->bgRed($this->white('NEW')) . ' ' . ltrim($line, '?? ');
55+
$line = $this->bgRed($this->white('NEW')).' '.ltrim($line, '?? ');
5456
}
5557
}
58+
5659
return implode("\n", $lines);
5760
}
5861

@@ -81,11 +84,11 @@ protected function tellJokeAndExit(): void
8184
'Attempting an empty commit? It’s as productive as a screen door on a submarine! 🛳️🚪',
8285
'Committing no changes? That’s like trying to tune a guitar with no strings! 🎸❌',
8386
'No changes? That’s like sending a love letter to an empty mailbox! 💌📪',
84-
"Trying to commit nothing? That’s as useful as a waterproof teabag! ☕🚫",
87+
'Trying to commit nothing? That’s as useful as a waterproof teabag! ☕🚫',
8588
'No changes to commit? Even ghosts leave more trace! 👻🕵️‍♂️',
8689
'Attempting an empty commit? That’s like cooking with imaginary ingredients! 🍳🥄',
8790
'No changes in your commit? That’s like racing in a stationary car! 🚗🛑',
88-
"Committing air? That’s like showing up to a concert with earplugs in! 🎤👂",
91+
'Committing air? That’s like showing up to a concert with earplugs in! 🎤👂',
8992
'Trying to commit with zero changes? That’s like playing soccer with an invisible ball! ⚽🕵️‍♀️',
9093
];
9194

@@ -111,9 +114,8 @@ private function ensureToolInstalled(
111114
string $successMessage,
112115
string $preCommand = '',
113116
string $preMessage = ''
114-
): void
115-
{
116-
if (!file_exists(base_path($path))) {
117+
): void {
118+
if (! file_exists(base_path($path))) {
117119
if (confirm($confirmMessage, true)) {
118120
if ($preCommand) {
119121
$this->info($preMessage);
@@ -133,8 +135,9 @@ protected function runPint(): void
133135
$outputFiles = $this->runTool('Laravel Pint', './vendor/bin/pint --dirty', '/^\s+√ (\S+)/m');
134136

135137
foreach ($outputFiles as $file) {
136-
if (!is_writable($file)) {
138+
if (! is_writable($file)) {
137139
$this->warn("File $file is not writable.");
140+
138141
continue;
139142
}
140143

@@ -153,8 +156,7 @@ private function runTool(
153156
string $regexPattern = '',
154157
string $errorKeyword1 = 'FAIL',
155158
string $errorKeyword2 = 'ERROR'
156-
): array
157-
{
159+
): array {
158160
$outputFiles = [];
159161
if (confirm("Would you like to run $toolName?", true)) {
160162
spin(
@@ -185,10 +187,10 @@ protected function stageFixedFiles(): void
185187
{
186188
$untrackedFiles = $this->getUntrackedFiles();
187189

188-
if (!empty($untrackedFiles)) {
190+
if (! empty($untrackedFiles)) {
189191
$this->info($this->red('Untracked files found:'));
190192
foreach ($untrackedFiles as $file) {
191-
$this->info($this->red(' ' . $file));
193+
$this->info($this->red(' '.$file));
192194
}
193195

194196
array_unshift($untrackedFiles, 'Select All', 'Select None');
@@ -209,7 +211,7 @@ protected function stageFixedFiles(): void
209211
}
210212

211213
$filesToDelete = array_diff($untrackedFiles, $selectedFiles, ['Select All', 'Select None']);
212-
if (!empty($filesToDelete) && confirm('Would you like to delete the unselected new files? You can delete it manually if you choose no.', false)) {
214+
if (! empty($filesToDelete) && confirm('Would you like to delete the unselected new files? You can delete it manually if you choose no.', false)) {
213215
foreach ($filesToDelete as $file) {
214216
unlink($file);
215217
$this->info("Deleted file: $file");
@@ -228,16 +230,17 @@ protected function stageFixedFiles(): void
228230

229231
protected function stageFile(string $file): void
230232
{
231-
shell_exec('git add ' . escapeshellarg($file));
232-
$stagedStatus = shell_exec('git status --porcelain ' . escapeshellarg($file));
233-
if (!empty($stagedStatus)) {
234-
$this->info("Staging status for $file: \n" . $stagedStatus);
233+
shell_exec('git add '.escapeshellarg($file));
234+
$stagedStatus = shell_exec('git status --porcelain '.escapeshellarg($file));
235+
if (! empty($stagedStatus)) {
236+
$this->info("Staging status for $file: \n".$stagedStatus);
235237
}
236238
}
237239

238240
protected function getUntrackedFiles(): array
239241
{
240242
$output = shell_exec('git ls-files --others --exclude-standard');
243+
241244
return array_filter(explode("\n", $output));
242245
}
243246

@@ -250,28 +253,27 @@ protected function commitChanges(): void
250253
}
251254

252255
$commitMessage = text('Enter the commit message');
253-
if (!$commitMessage) {
256+
if (! $commitMessage) {
254257
$this->error('Commit message cannot be empty.');
255258
exit(1);
256259
}
257260

258-
shell_exec('git commit -m ' . escapeshellarg($commitMessage));
261+
shell_exec('git commit -m '.escapeshellarg($commitMessage));
259262
$this->info('Changes committed.');
260263

261264
$currentBranch = $this->getCurrentBranch();
262265

263-
264266
if (confirm("We will push this to branch [$currentBranch].", true)) {
265267
$this->info("Pushing code to branch $currentBranch...");
266268

267-
spin(fn() => $this->pushToBranch($currentBranch), "Pushing code to $currentBranch...");
269+
spin(fn () => $this->pushToBranch($currentBranch), "Pushing code to $currentBranch...");
268270

269271
$commitHash = trim(shell_exec('git log -1 --format="%H"'));
270272
$gitUserName = trim(shell_exec('git config user.name'));
271273
$this->info("Commit hash: $commitHash");
272274
$this->info("Pushed by: $gitUserName");
273275
} else {
274-
$this->info("Exiting. No changes will be pushed to the server, but changes have been committed locally.");
276+
$this->info('Exiting. No changes will be pushed to the server, but changes have been committed locally.');
275277
}
276278
}
277279

0 commit comments

Comments
 (0)