mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
The repository URL rule rejected ssh://user@host:port/path, so deploy-key resources on servers with a custom SSH port needed a manual URL edit after creation. Accept ssh:// URLs and keep them unchanged for deploy keys so the port reaches the clone. Rename scpStyleGitUrlToHttps to sshGitUrlToHttps and let it convert ssh:// URLs too, so public flows, repository links and GitHub App repository slugs handle them. Closes #12161 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
3.6 KiB
PHP
86 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Models\Application;
|
|
|
|
it('generates commit links for direct repository remotes', function (string $repository, string $expected) {
|
|
$application = new Application;
|
|
$application->setRelation('source', null);
|
|
$application->git_repository = $repository;
|
|
|
|
expect($application->gitCommitLink('1234567890abcdef'))->toBe($expected);
|
|
})->with([
|
|
'HTTPS remote' => [
|
|
'https://github.com/coollabsio/coolify.git',
|
|
'https://github.com/coollabsio/coolify/commit/1234567890abcdef',
|
|
],
|
|
'SSH remote' => [
|
|
'git@github.com:coollabsio/coolify.git',
|
|
'https://github.com/coollabsio/coolify/commit/1234567890abcdef',
|
|
],
|
|
'SSH remote with custom username' => [
|
|
'custom-user@git.example.com:coollabsio/coolify.git',
|
|
'https://git.example.com/coollabsio/coolify/commit/1234567890abcdef',
|
|
],
|
|
'SSH remote with custom username and port' => [
|
|
'custom-user@git.example.com:2222/coollabsio/coolify.git',
|
|
'https://git.example.com/coollabsio/coolify/commit/1234567890abcdef',
|
|
],
|
|
'SSH URL' => [
|
|
'ssh://git@gitlab.com/coollabsio/coolify.git',
|
|
'https://gitlab.com/coollabsio/coolify/commit/1234567890abcdef',
|
|
],
|
|
'Bitbucket HTTPS remote' => [
|
|
'https://bitbucket.org/coollabsio/coolify.git',
|
|
'https://bitbucket.org/coollabsio/coolify/commits/1234567890abcdef',
|
|
],
|
|
]);
|
|
|
|
it('does not generate commit links from incomplete repository URLs', function (string $repository) {
|
|
$application = new Application;
|
|
$application->setRelation('source', null);
|
|
$application->git_repository = $repository;
|
|
|
|
expect($application->gitCommitLink('1234567890abcdef'))->toBeNull();
|
|
})->with([
|
|
'missing host' => 'https://',
|
|
'missing scheme' => 'github.com/coollabsio/coolify',
|
|
'git protocol' => 'git://git.example.com/coollabsio/coolify.git',
|
|
]);
|
|
|
|
it('converts ssh remotes with generic usernames into https repository links', function (string $repository, string $expectedBranch, string $expectedCommits, string $expectedWebhook) {
|
|
$application = new Application;
|
|
$application->setRelation('source', null);
|
|
$application->git_repository = $repository;
|
|
$application->git_branch = 'main';
|
|
$application->base_directory = '/';
|
|
|
|
expect($application->gitBranchLocation)->toBe($expectedBranch)
|
|
->and($application->gitCommits)->toBe($expectedCommits)
|
|
->and($application->gitWebhook)->toBe($expectedWebhook);
|
|
})->with([
|
|
'git username' => [
|
|
'git@github.com:coollabsio/coolify.git',
|
|
'https://github.com/coollabsio/coolify/tree/main/',
|
|
'https://github.com/coollabsio/coolify/commits/main',
|
|
'https://github.com/coollabsio/coolify/settings/hooks',
|
|
],
|
|
'custom username' => [
|
|
'custom-user@git.example.com:organization/repository.git',
|
|
'https://git.example.com/organization/repository/tree/main/',
|
|
'https://git.example.com/organization/repository/commits/main',
|
|
'https://git.example.com/organization/repository/settings/hooks',
|
|
],
|
|
'custom username and port' => [
|
|
'custom-user@git.example.com:2222/organization/repository.git',
|
|
'https://git.example.com/organization/repository/tree/main/',
|
|
'https://git.example.com/organization/repository/commits/main',
|
|
'https://git.example.com/organization/repository/settings/hooks',
|
|
],
|
|
'ssh scheme with port' => [
|
|
'ssh://git@gitea.example.com:2222/organization/repository.git',
|
|
'https://gitea.example.com/organization/repository/tree/main/',
|
|
'https://gitea.example.com/organization/repository/commits/main',
|
|
'https://gitea.example.com/organization/repository/settings/hooks',
|
|
],
|
|
]);
|