Add ticket-driven branch creation flow
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Git;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BuildSuggestedTicketBranchName
|
||||
{
|
||||
public function handle(Ticket $ticket): string
|
||||
{
|
||||
$titleSlug = Str::of($ticket->title)
|
||||
->lower()
|
||||
->replaceMatches('/[^a-z0-9\s-]+/', '')
|
||||
->trim()
|
||||
->replaceMatches('/\s+/', '-')
|
||||
->replaceMatches('/-+/', '-')
|
||||
->value();
|
||||
|
||||
$ticketKey = Str::lower($ticket->ticket_key);
|
||||
|
||||
if ($titleSlug === '') {
|
||||
return $ticketKey;
|
||||
}
|
||||
|
||||
return "{$ticketKey}-{$titleSlug}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user