diff --git a/app/Filament/Pages/DeploymentPackage.php b/app/Filament/Pages/DeploymentPackage.php index 8d4144a..2ab29f0 100644 --- a/app/Filament/Pages/DeploymentPackage.php +++ b/app/Filament/Pages/DeploymentPackage.php @@ -99,8 +99,8 @@ public function form(Schema $form): Schema ->live(), TextInput::make('search') ->label('Keresés') - ->placeholder('hash, üzenet vagy szerző') - ->helperText('A betöltött listán belül szűr.') + ->placeholder('pl. árlista, migráció, szerző') + ->helperText('A commit üzenetében (a törzsben is), a szerzőben és a hashben keres, a betöltött listán belül.') ->live(debounce: 400), ]), ]) @@ -143,7 +143,7 @@ public function target(): ?array } /** - * @return array + * @return array */ #[Computed] public function commits(): array @@ -168,9 +168,14 @@ public function commits(): array return $commits; } + $needle = mb_strtolower($search); + return array_values(array_filter( $commits, - fn (array $commit): bool => str_contains(mb_strtolower($commit['subject'].' '.$commit['author'].' '.$commit['hash']), mb_strtolower($search)), + fn (array $commit): bool => str_contains( + mb_strtolower(implode(' ', [$commit['subject'], $commit['body'], $commit['author'], $commit['hash']])), + $needle, + ), )); } diff --git a/app/Services/Deployment/GitRepository.php b/app/Services/Deployment/GitRepository.php index 8e13031..4d84b2f 100644 --- a/app/Services/Deployment/GitRepository.php +++ b/app/Services/Deployment/GitRepository.php @@ -73,17 +73,20 @@ public function branches(): array /** * Commitlista egy referenciáról, legfrissebbtől visszafelé. * - * A --shortstat miatt minden commit után megjelenik a "N files changed" sor is, - * ezt az utolsó mezőből (a tárgyból) bányásszuk ki - így nem kell commitonként - * külön git hívás a fájlszámhoz. + * A törzset (%b) is elkérjük, mert a felületen erre is lehet keresni - a commit + * üzenet érdemi része nálunk gyakran a törzsben van, nem a tárgysorban. * - * @return array + * A --shortstat miatt minden commit után megjelenik a "N files changed" sor is, + * ezt az utolsó mezőből bányásszuk ki - így nem kell commitonként külön git hívás + * a fájlszámhoz. + * + * @return array */ public function commits(string $reference, int $limit): array { $this->assertReference($reference); - $format = self::RECORD_SEPARATOR.implode(self::FIELD_SEPARATOR, ['%H', '%h', '%an', '%aI', '%s']); + $format = self::RECORD_SEPARATOR.implode(self::FIELD_SEPARATOR, ['%H', '%h', '%an', '%aI', '%s', '%b']); $output = $this->run([ 'log', @@ -102,23 +105,31 @@ public function commits(string $reference, int $limit): array continue; } - $fields = explode(self::FIELD_SEPARATOR, $record, 5); + $fields = explode(self::FIELD_SEPARATOR, $record, 6); - if (count($fields) < 5) { + if (count($fields) < 6) { continue; } - [$hash, $short, $author, $date, $tail] = $fields; + [$hash, $short, $author, $date, $subject, $tail] = $fields; + + // A --shortstat sora a törzs UTÁN érkezik, ezért előbb leválasztjuk róla: + // enélkül a "3 files changed" szöveg a keresésbe és a törzsbe is beszivárogna. + $fileCount = null; + + if (preg_match('/\n\s*(\d+)\s+files?\s+changed[^\n]*\n?$/', $tail, $matches) === 1) { + $fileCount = (int) $matches[1]; + $tail = substr($tail, 0, -strlen($matches[0])); + } $commits[] = [ 'hash' => $hash, 'short' => $short, 'author' => $author, 'date' => $date, - 'subject' => trim(explode("\n", $tail, 2)[0]), - 'file_count' => preg_match('/(\d+)\s+files?\s+changed/', $tail, $matches) === 1 - ? (int) $matches[1] - : null, + 'subject' => trim($subject), + 'body' => trim($tail), + 'file_count' => $fileCount, ]; } diff --git a/public/images/icons/ico_git.png b/public/images/icons/ico_git.png new file mode 100644 index 0000000..667bc5e Binary files /dev/null and b/public/images/icons/ico_git.png differ diff --git a/resources/views/filament/components/speed-button-nav-bar.blade.php b/resources/views/filament/components/speed-button-nav-bar.blade.php index b2c71a3..ad54243 100644 --- a/resources/views/filament/components/speed-button-nav-bar.blade.php +++ b/resources/views/filament/components/speed-button-nav-bar.blade.php @@ -45,7 +45,7 @@ // .env kapcsoló + stage whitelist + developer szerep + feature flag), ezért a // menüpont a szervereken akkor sem jelenik meg, ha a kód oda is felmásolódik. if (\App\Filament\Pages\DeploymentPackage::canAccess()) { - $modules[] = ['name' => 'deploymentPackage', 'displayName' => 'Deployment', 'icon' => 'upload', 'link' => \App\Filament\Pages\DeploymentPackage::getUrl(), 'roles' => ['root','developer']]; + $modules[] = ['name' => 'deploymentPackage', 'displayName' => 'Deployment', 'icon' => 'git', 'link' => \App\Filament\Pages\DeploymentPackage::getUrl(), 'roles' => ['root','developer']]; } @endphp diff --git a/resources/views/layout/speedButtonNavBar.blade.php b/resources/views/layout/speedButtonNavBar.blade.php index 77c9724..12ec7c1 100644 --- a/resources/views/layout/speedButtonNavBar.blade.php +++ b/resources/views/layout/speedButtonNavBar.blade.php @@ -179,7 +179,7 @@ $Modules['deploymentPackage'] = [ 'name' => 'deploymentPackage', 'DisplayName' => 'Deployment', - 'icon' => 'upload', + 'icon' => 'git', 'link' => \App\Filament\Pages\DeploymentPackage::getUrl(), 'noAjax' => true, 'roles' => ['root', 'developer'], diff --git a/tests/Feature/DeploymentPackageTest.php b/tests/Feature/DeploymentPackageTest.php index c35fc51..dd27870 100644 --- a/tests/Feature/DeploymentPackageTest.php +++ b/tests/Feature/DeploymentPackageTest.php @@ -87,7 +87,7 @@ function deploymentTestRepository(): array File::put($path.'/database/migrations/2026_01_01_000000_teszt.php', "and($commits[0]['subject'])->toBe('harmadik commit') ->and($commits[2]['subject'])->toBe('első commit') ->and($commits[0]['hash'])->toHaveLength(40) - ->and($commits[0]['file_count'])->toBe(2); + ->and($commits[0]['file_count'])->toBe(2) + // A törzs a tárgysor nélkül jön, és nem tapad hozzá a --shortstat sora sem. + ->and($commits[1]['body'])->toBe('A törzsben említett árlista részlet.') + ->and($commits[0]['body'])->toBe(''); + + deploymentCleanup($repository['path']); +}); + +test('a keresés a commit törzsében is talál, nem csak a tárgysorban', function () { + deploymentAllowEnvironment(); + $repository = deploymentTestRepository(); + + $this->actingAs(deploymentDeveloper()); + + Livewire::test(DeploymentPackage::class) + ->set('data.search', 'árlista részlet') + ->assertSee('második commit') + ->assertDontSee('harmadik commit'); deploymentCleanup($repository['path']); });