Skip to content

Commit fdc0002

Browse files
committed
Adds gitlab ssh url support
1 parent 3fc43ab commit fdc0002

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

composer-lock-diff

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ function getSourceRepoType($url) {
219219
if (preg_match('/^git@github.com:(.*)\.git$/', $url)) {
220220
return 'github';
221221
}
222+
if (preg_match('/^git@gitlab\..+:.+\.git$/', $url)) {
223+
return 'gitlab';
224+
}
225+
222226
if (! preg_match('/^http/i', $url)) {
223227
return 'unknown';
224228
}
@@ -251,7 +255,11 @@ function formatCompareBitbucket($url, $from, $to) {
251255
}
252256

253257
function formatCompareGitlab($url, $from, $to) {
254-
return sprintf('%s/compare/%s...%s', preg_replace('/\.git$/', '', $url), urlencode($from), urlencode($to));
258+
if (strpos($url, 'http') === false) {
259+
$url = preg_replace('/^git@(gitlab\.[^:]+):/', 'https://$1/', $url);
260+
}
261+
$url = preg_replace('/\.git$/', '', $url);
262+
return sprintf('%s/compare/%s...%s', $url, urlencode($from), urlencode($to));
255263
}
256264

257265
function parseOpts() {

0 commit comments

Comments
 (0)