DEleted function in request and changed the way the controller uses it,
linter / quality (pull_request) Successful in 1m13s
tests / ci (8.4) (pull_request) Failing after 1m15s

This commit is contained in:
Eric Peters
2026-04-03 16:50:00 +02:00
parent 2c1a0cbff3
commit 1c355c20b4
27 changed files with 285 additions and 263 deletions
@@ -14,6 +14,7 @@ use App\Models\Ticket;
use App\Models\UserGitConnection;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException;
use Throwable;
@@ -30,17 +31,23 @@ class ProjectTicketBranchController extends Controller
Project $project,
Ticket $ticket,
): JsonResponse {
$user = $request->user();
abort_unless(
$this->projectPermissionService->userHasPermission($request->user(), $project, 'edit'),
$this->projectPermissionService->userHasPermission($user, $project, 'edit'),
403,
);
$validated = $request->validated();
$repositoryConnectionId = Arr::get($validated, 'repository_connection_id');
$branchName = trim((string) Arr::get($validated, 'branch_name'));
$repositoryConnection = $this->projectRepositoryConnection(
$project,
$request->repositoryConnectionId(),
$repositoryConnectionId,
);
$userGitConnection = $this->matchingUserGitConnection(
$request->user()->id,
$user->id,
$repositoryConnection,
);
@@ -51,7 +58,7 @@ class ProjectTicketBranchController extends Controller
]);
}
$syntaxMessage = $this->validateGitBranchName->message($request->branchName());
$syntaxMessage = $this->validateGitBranchName->message($branchName);
if ($syntaxMessage !== null) {
return response()->json([
@@ -72,7 +79,7 @@ class ProjectTicketBranchController extends Controller
),
)
->contains(
fn (GitBranch $branch): bool => $branch->name === $request->branchName(),
fn (GitBranch $branch): bool => $branch->name === $branchName,
);
} catch (Throwable) {
return response()->json([
@@ -99,17 +106,26 @@ class ProjectTicketBranchController extends Controller
Project $project,
Ticket $ticket,
): RedirectResponse {
$user = $request->user();
abort_unless(
$this->projectPermissionService->userHasPermission($request->user(), $project, 'edit'),
$this->projectPermissionService->userHasPermission($user, $project, 'edit'),
403,
);
$validated = $request->validated();
$repositoryConnectionId = Arr::get($validated, 'repository_connection_id');
$branchName = trim((string) Arr::get($validated, 'branch_name'));
$repositoryConnection = $this->projectRepositoryConnection(
$project,
$request->repositoryConnectionId(),
$repositoryConnectionId,
);
$userGitConnection = $this->matchingUserGitConnection(
$request->user()->id,
$user->id,
$repositoryConnection,
);
@@ -119,7 +135,7 @@ class ProjectTicketBranchController extends Controller
]);
}
$syntaxMessage = $this->validateGitBranchName->message($request->branchName());
$syntaxMessage = $this->validateGitBranchName->message($branchName);
if ($syntaxMessage !== null) {
throw ValidationException::withMessages([
@@ -139,7 +155,7 @@ class ProjectTicketBranchController extends Controller
),
)
->contains(
fn (GitBranch $branch): bool => $branch->name === $request->branchName(),
fn (GitBranch $branch): bool => $branch->name === $branchName,
);
} catch (Throwable) {
throw ValidationException::withMessages([
@@ -166,7 +182,7 @@ class ProjectTicketBranchController extends Controller
$userGitConnection->api_token,
$repositoryConnection->owner_name,
$repositoryConnection->repository_name,
$request->branchName(),
$branchName,
$repository->defaultBranch,
);
} catch (Throwable) {
@@ -178,7 +194,7 @@ class ProjectTicketBranchController extends Controller
return to_route('projects.tickets.show', [$project, $ticket])
->with(
'status',
"{$request->branchName()} was created in {$repositoryConnection->repository_full_name}.",
"{$branchName} was created in {$repositoryConnection->repository_full_name}.",
);
}