Add ticket-driven branch creation flow

This commit is contained in:
2026-03-26 09:39:18 +01:00
parent 789675f83f
commit 92dfe3840c
47 changed files with 1332 additions and 50 deletions
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace App\Actions\Git;
class ValidateGitBranchName
{
public function message(string $branchName): ?string
{
$trimmedBranchName = trim($branchName);
if ($trimmedBranchName === '') {
return 'Branch name is required.';
}
if (preg_match('/\s/', $trimmedBranchName) === 1) {
return 'Branch names must not contain whitespace.';
}
if (
str_starts_with($trimmedBranchName, '/') ||
str_ends_with($trimmedBranchName, '/') ||
str_starts_with($trimmedBranchName, '.') ||
str_ends_with($trimmedBranchName, '.')
) {
return 'Branch names must not start or end with "/" or ".".';
}
if (
str_contains($trimmedBranchName, '..') ||
str_contains($trimmedBranchName, '//') ||
str_contains($trimmedBranchName, '@{')
) {
return 'Branch names contain an unsupported ref pattern.';
}
if (preg_match('/[~^:?*\[\\\\]/', $trimmedBranchName) === 1) {
return 'Branch names contain unsupported characters.';
}
if (str_ends_with($trimmedBranchName, '.lock')) {
return 'Branch names must not end with ".lock".';
}
if (preg_match('/[\x00-\x1F\x7F]/', $trimmedBranchName) === 1) {
return 'Branch names contain unsupported control characters.';
}
return null;
}
}