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:
parent
09eed3eeb3
commit
6027511585
@ -99,8 +99,8 @@ public function form(Schema $form): Schema
|
|||||||
->live(),
|
->live(),
|
||||||
TextInput::make('search')
|
TextInput::make('search')
|
||||||
->label('Keresés')
|
->label('Keresés')
|
||||||
->placeholder('hash, üzenet vagy szerző')
|
->placeholder('pl. árlista, migráció, szerző')
|
||||||
->helperText('A betöltött listán belül szűr.')
|
->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),
|
->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]
|
#[Computed]
|
||||||
public function commits(): array
|
public function commits(): array
|
||||||
@ -168,9 +168,14 @@ public function commits(): array
|
|||||||
return $commits;
|
return $commits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$needle = mb_strtolower($search);
|
||||||
|
|
||||||
return array_values(array_filter(
|
return array_values(array_filter(
|
||||||
$commits,
|
$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,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,17 +73,20 @@ public function branches(): array
|
|||||||
/**
|
/**
|
||||||
* Commitlista egy referenciáról, legfrissebbtől visszafelé.
|
* Commitlista egy referenciáról, legfrissebbtől visszafelé.
|
||||||
*
|
*
|
||||||
* A --shortstat miatt minden commit után megjelenik a "N files changed" sor is,
|
* A törzset (%b) is elkérjük, mert a felületen erre is lehet keresni - a commit
|
||||||
* ezt az utolsó mezőből (a tárgyból) bányásszuk ki - így nem kell commitonként
|
* üzenet érdemi része nálunk gyakran a törzsben van, nem a tárgysorban.
|
||||||
* 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, 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
|
public function commits(string $reference, int $limit): array
|
||||||
{
|
{
|
||||||
$this->assertReference($reference);
|
$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([
|
$output = $this->run([
|
||||||
'log',
|
'log',
|
||||||
@ -102,23 +105,31 @@ public function commits(string $reference, int $limit): array
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = explode(self::FIELD_SEPARATOR, $record, 5);
|
$fields = explode(self::FIELD_SEPARATOR, $record, 6);
|
||||||
|
|
||||||
if (count($fields) < 5) {
|
if (count($fields) < 6) {
|
||||||
continue;
|
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[] = [
|
$commits[] = [
|
||||||
'hash' => $hash,
|
'hash' => $hash,
|
||||||
'short' => $short,
|
'short' => $short,
|
||||||
'author' => $author,
|
'author' => $author,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'subject' => trim(explode("\n", $tail, 2)[0]),
|
'subject' => trim($subject),
|
||||||
'file_count' => preg_match('/(\d+)\s+files?\s+changed/', $tail, $matches) === 1
|
'body' => trim($tail),
|
||||||
? (int) $matches[1]
|
'file_count' => $fileCount,
|
||||||
: null,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
public/images/icons/ico_git.png
Normal file
BIN
public/images/icons/ico_git.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@ -45,7 +45,7 @@
|
|||||||
// .env kapcsoló + stage whitelist + developer szerep + feature flag), ezért a
|
// .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.
|
// menüpont a szervereken akkor sem jelenik meg, ha a kód oda is felmásolódik.
|
||||||
if (\App\Filament\Pages\DeploymentPackage::canAccess()) {
|
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
|
@endphp
|
||||||
|
|
||||||
|
|||||||
@ -179,7 +179,7 @@
|
|||||||
$Modules['deploymentPackage'] = [
|
$Modules['deploymentPackage'] = [
|
||||||
'name' => 'deploymentPackage',
|
'name' => 'deploymentPackage',
|
||||||
'DisplayName' => 'Deployment',
|
'DisplayName' => 'Deployment',
|
||||||
'icon' => 'upload',
|
'icon' => 'git',
|
||||||
'link' => \App\Filament\Pages\DeploymentPackage::getUrl(),
|
'link' => \App\Filament\Pages\DeploymentPackage::getUrl(),
|
||||||
'noAjax' => true,
|
'noAjax' => true,
|
||||||
'roles' => ['root', 'developer'],
|
'roles' => ['root', 'developer'],
|
||||||
|
|||||||
@ -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.'/database/migrations/2026_01_01_000000_teszt.php', "<?php\n// migracio\n");
|
||||||
File::put($path.'/.env', "APP_KEY=titok\n");
|
File::put($path.'/.env', "APP_KEY=titok\n");
|
||||||
deploymentGit($path, ['add', '-A', '-f']);
|
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, ['mv', 'app/Atnevezendo.php', 'app/Atnevezett.php']);
|
||||||
deploymentGit($path, ['rm', 'app/Regi.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[0]['subject'])->toBe('harmadik commit')
|
||||||
->and($commits[2]['subject'])->toBe('első commit')
|
->and($commits[2]['subject'])->toBe('első commit')
|
||||||
->and($commits[0]['hash'])->toHaveLength(40)
|
->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']);
|
deploymentCleanup($repository['path']);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user