FIX Deployment csomagoló phase1 git ikon és a commit törzsére kiterjesztett keresés

- a topbar menüpont a most bemásolt git ikont használja; a fájl ico_gitpng néven
  érkezett, átnevezve ico_git.png-re, hogy illeszkedjen az ico_*.png konvencióhoz,
  amiből a nav az útvonalat építi
- a git log a törzset (%b) is elkéri, és a keresés a tárgysor mellett ebben is keres:
  a hash-re ritkán keres ember, az érdemi leírás viszont gyakran a törzsben van
- a --shortstat sora a törzs után érkezik, ezért a parse leválasztja róla, különben
  a "N files changed" szöveg a törzsbe és a keresésbe is beszivárogna

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
E98Developer 2026-08-16 06:59:04 +02:00
parent 09eed3eeb3
commit 6027511585
6 changed files with 53 additions and 20 deletions

View File

@ -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<int, array{hash:string, short:string, author:string, date:string, subject:string, file_count:?int}>
* @return array<int, array{hash:string, short:string, author:string, date:string, subject:string, body:string, file_count:?int}>
*/
#[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,
),
));
}

View File

@ -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<int, array{hash:string, short:string, author:string, date:string, subject:string, file_count:?int}>
* 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<int, array{hash:string, short:string, author:string, date:string, subject:string, body:string, file_count:?int}>
*/
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,
];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -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

View File

@ -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'],

View File

@ -87,7 +87,7 @@ function deploymentTestRepository(): array
File::put($path.'/database/migrations/2026_01_01_000000_teszt.php', "<?php\n// migracio\n");
File::put($path.'/.env', "APP_KEY=titok\n");
deploymentGit($path, ['add', '-A', '-f']);
deploymentGit($path, ['commit', '-m', 'második commit']);
deploymentGit($path, ['commit', '-m', "második commit\n\nA törzsben említett árlista részlet."]);
deploymentGit($path, ['mv', 'app/Atnevezendo.php', 'app/Atnevezett.php']);
deploymentGit($path, ['rm', 'app/Regi.php']);
@ -189,7 +189,24 @@ function deploymentCleanup(string $path): void
->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']);
});