mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Furox <177975472+Furox-Art@users.noreply.github.com> Co-authored-by: johandenhollander <johan.den.hollander@finalist.nl> Co-authored-by: João Cruz <161638790+SrJooJ@users.noreply.github.com> Co-authored-by: Saim Hashmi <hashmisaim037@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
106 lines
4.0 KiB
PHP
106 lines
4.0 KiB
PHP
<?php
|
|
|
|
it('parses scp-style ssh git urls including custom usernames and ports', function (string $url, array $expected) {
|
|
expect(parseScpStyleGitUrl($url))->toBe($expected);
|
|
})->with([
|
|
'git username' => [
|
|
'git@github.com:organization/repository.git',
|
|
[
|
|
'user' => 'git',
|
|
'host' => 'github.com',
|
|
'port' => null,
|
|
'path' => 'organization/repository.git',
|
|
],
|
|
],
|
|
'custom username' => [
|
|
'custom-user@git.example.com:organization/repository.git',
|
|
[
|
|
'user' => 'custom-user',
|
|
'host' => 'git.example.com',
|
|
'port' => null,
|
|
'path' => 'organization/repository.git',
|
|
],
|
|
],
|
|
'custom username and port' => [
|
|
'custom-user@git.example.com:2222/organization/repository.git',
|
|
[
|
|
'user' => 'custom-user',
|
|
'host' => 'git.example.com',
|
|
'port' => '2222',
|
|
'path' => 'organization/repository.git',
|
|
],
|
|
],
|
|
'IPv6 host' => [
|
|
'git@[2a01:4f8::1]:organization/repository.git',
|
|
[
|
|
'user' => 'git',
|
|
'host' => '[2a01:4f8::1]',
|
|
'port' => null,
|
|
'path' => 'organization/repository.git',
|
|
],
|
|
],
|
|
'IPv6 host and port' => [
|
|
'git@[fd00::5]:2222/organization/repository.git',
|
|
[
|
|
'user' => 'git',
|
|
'host' => '[fd00::5]',
|
|
'port' => '2222',
|
|
'path' => 'organization/repository.git',
|
|
],
|
|
],
|
|
]);
|
|
|
|
it('converts ssh git urls to https without embedding custom ports in the path', function (string $url, string $expected) {
|
|
expect(sshGitUrlToHttps($url))->toBe($expected);
|
|
})->with([
|
|
'git username' => [
|
|
'git@github.com:organization/repository.git',
|
|
'https://github.com/organization/repository.git',
|
|
],
|
|
'custom username' => [
|
|
'custom-user@git.example.com:organization/repository.git',
|
|
'https://git.example.com/organization/repository.git',
|
|
],
|
|
'custom username and port' => [
|
|
'custom-user@git.example.com:2222/organization/repository.git',
|
|
'https://git.example.com/organization/repository.git',
|
|
],
|
|
'IPv6 host and port' => [
|
|
'git@[fd00::5]:2222/organization/repository.git',
|
|
'https://[fd00::5]/organization/repository.git',
|
|
],
|
|
'ssh scheme' => [
|
|
'ssh://git@github.com/organization/repository.git',
|
|
'https://github.com/organization/repository.git',
|
|
],
|
|
'ssh scheme with port' => [
|
|
'ssh://git@gitea.example.com:2222/organization/repository.git',
|
|
'https://gitea.example.com/organization/repository.git',
|
|
],
|
|
'ssh scheme with IPv6 host and port' => [
|
|
'ssh://git@[fd00::5]:2222/organization/repository.git',
|
|
'https://[fd00::5]/organization/repository.git',
|
|
],
|
|
]);
|
|
|
|
it('rejects non-scp-style git urls', function (string $url) {
|
|
expect(parseScpStyleGitUrl($url))->toBeNull()
|
|
->and(sshGitUrlToHttps($url))->toBeNull();
|
|
})->with([
|
|
'https' => 'https://github.com/organization/repository.git',
|
|
'email without path' => 'custom-user@git.example.com',
|
|
'empty' => '',
|
|
]);
|
|
|
|
it('normalizes github app repository slugs from ssh urls', function (string $url, string $expected) {
|
|
expect(gitRepositorySlug($url))->toBe($expected);
|
|
})->with([
|
|
'https' => ['https://github.com/organization/repository.git', 'organization/repository'],
|
|
'owner/repo' => ['organization/repository', 'organization/repository'],
|
|
'git username' => ['git@github.com:organization/repository.git', 'organization/repository'],
|
|
'custom username' => ['custom-user@git.example.com:organization/repository.git', 'organization/repository'],
|
|
'custom username and port' => ['custom-user@git.example.com:2222/organization/repository.git', 'organization/repository'],
|
|
'ssh scheme' => ['ssh://git@github.com/organization/repository.git', 'organization/repository'],
|
|
'ssh scheme with port' => ['ssh://git@ghe.example.com:2222/organization/repository.git', 'organization/repository'],
|
|
]);
|