[go: up one dir, main page]

Skip to content

Use alternate SSH git clone URL format

I suggest GitLab CE uses the alternate syntax for SSH clone URLs, using a slash instead of a colon in between the host & path URL parts:

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
                                    prefer the slash here ^

Why?

Because of this npm bug between npm -v 5.1 and up to at least 5.6 (roughly node -v 8-10), semver ranges don't work if the URL uses the colon, but does work with slashes.

I've also suggested updating the examples in the official npm docs and created a stackoverflow question to help people avoid this bug.

Examples

These URLs work:

# with slash between host & path
git+ssh://git@gitlab.example.com/path/repo.git
git+ssh://git@gitlab.example.com/path/repo.git#branch_1_2
git+ssh://git@gitlab.example.com/path/repo.git#1.2.3
git+ssh://git@gitlab.example.com/path/repo.git#semver:^1.2.3
git+ssh://git@gitlab.example.com/path/repo.git#semver:~1.2.3

# with colon between host & path
git+ssh://git@gitlab.example.com:path/repo.git
git+ssh://git@gitlab.example.com:path/repo.git#branch_1_2
git+ssh://git@gitlab.example.com:path/repo.git#1.2.3

but this doesn't work (depending on the npm version):

# with colon between host & path
git+ssh://git@gitlab.example.com:path/repo.git#semver:^1.2.3
git+ssh://git@gitlab.example.com:path/repo.git#semver:~1.2.3
Edited by DJDaveMark