Skip to content

Commit 8ea005a

Browse files
ihor-svizievdavidrjonas
authored andcommitted
Add support of git@bitbucket.org and git@github.com repos (#19)
* Add support of git@bitbucket.org and git@github.com repos * Add support of git@bitbucket.org and git@github.com repos * Add support of git@bitbucket.org and git@github.com repos Fix compare links for bitbucket
1 parent d3198dd commit 8ea005a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

composer-lock-diff

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ function makeCompareUrl($pkg, $diff) {
214214
}
215215

216216
function getSourceRepoType($url) {
217+
if (preg_match('/^git@bitbucket.org:(.*)\.git$/', $url)) {
218+
return 'bitbucket';
219+
}
220+
if (preg_match('/^git@github.com:(.*)\.git$/', $url)) {
221+
return 'github';
222+
}
217223
if (! preg_match('/^http/i', $url)) {
218224
return 'unknown';
219225
}
@@ -236,11 +242,13 @@ function formatCompareUnknown($url, $from, $to) {
236242
}
237243

238244
function formatCompareGithub($url, $from, $to) {
239-
return sprintf('%s/compare/%s...%s', preg_replace('/\.git$/', '', $url), urlencode($from), urlencode($to));
245+
$url = preg_replace(['/\.git$/', '/^git@github.com:/'], ['', 'https://github.com/'], $url);
246+
return sprintf('%s/compare/%s...%s', $url, urlencode($from), urlencode($to));
240247
}
241248

242249
function formatCompareBitbucket($url, $from, $to) {
243-
return sprintf('%s/branches/compare/%s%%0D%s', preg_replace('/\.git$/', '', $url), urlencode($from), urlencode($to));
250+
$url = preg_replace(['/\.git$/', '/^git@bitbucket.org:/'], ['', 'https://bitbucket.org/'], $url);
251+
return sprintf('%s/branches/compare/%s%%0D%s', $url, urlencode($to), urlencode($from));
244252
}
245253

246254
function formatCompareGitlab($url, $from, $to) {

0 commit comments

Comments
 (0)