Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions bootstrap/helpers/shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\ApplicationPreview;
use App\Models\EnvironmentVariable;
use App\Models\GithubApp;
use App\Models\GitlabApp;
use App\Models\InstanceSettings;
use App\Models\LocalFileVolume;
use App\Models\LocalPersistentVolume;
Expand Down Expand Up @@ -3014,7 +3015,7 @@ function defaultNginxConfiguration(string $type = 'static'): string
}
}

function convertGitUrl(string $gitRepository, string $deploymentType, ?GithubApp $source = null): array
function convertGitUrl(string $gitRepository, string $deploymentType, GithubApp|GitlabApp|null $source = null): array
{
$repository = $gitRepository;
$providerInfo = [
Expand All @@ -3029,13 +3030,27 @@ function convertGitUrl(string $gitRepository, string $deploymentType, ?GithubApp
// Let's try and parse the string to detect if it's a valid SSH string or not
preg_match('/((.*?)\:\/\/)?(.*@.*:.*)/', $gitRepository, $sshMatches);

// Extract custom port from source for GitLab/GitHub apps with custom ports
// This handles SCP-style URLs like git@host:repo.git where host uses non-standard port
if ($deploymentType === 'deploy_key' && $source && ! empty($sshMatches)) {
switch ($source->getMorphClass()) {
case \App\Models\GithubApp::class:
case \App\Models\GitlabApp::class:
if ($source->custom_port !== null && (int) $source->custom_port !== 22) {
$providerInfo['port'] = (int) $source->custom_port;
}
break;
}
}

if ($deploymentType === 'deploy_key' && empty($sshMatches) && $source) {
// If this happens, the user may have provided an HTTP URL when they needed an SSH one
// Let's try and fix that for known Git providers
switch ($source->getMorphClass()) {
case \App\Models\GithubApp::class:
case \App\Models\GitlabApp::class:
$providerInfo['host'] = Url::fromString($source->html_url)->getHost();
$providerInfo['port'] = $source->custom_port;
$providerInfo['port'] = ($source->custom_port !== null && $source->custom_port !== '' && (int) $source->custom_port !== 22) ? (int) $source->custom_port : 22;
$providerInfo['user'] = $source->custom_user;
break;
}
Expand Down