Skip to content

Commit

Permalink
Improve github, bitbucket url matchers, php 5.3 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
djonas-noip committed Aug 7, 2019
1 parent fdc0002 commit 817bb8f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions composer-lock-diff
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ function makeCompareUrl($pkg, $diff) {
}

function getSourceRepoType($url) {
if (preg_match('/^git@bitbucket.org:(.*)\.git$/', $url)) {
if (preg_match('/^git@bitbucket\..+:.+\.git$/', $url)) {
return 'bitbucket';
}
if (preg_match('/^git@github.com:(.*)\.git$/', $url)) {
if (preg_match('/^git@github\..+:.+\.git$/', $url)) {
return 'github';
}
if (preg_match('/^git@gitlab\..+:.+\.git$/', $url)) {
Expand Down Expand Up @@ -245,12 +245,18 @@ function formatCompareUnknown($url, $from, $to) {
}

function formatCompareGithub($url, $from, $to) {
$url = preg_replace(['/\.git$/', '/^[email protected]:/'], ['', 'https://github.com/'], $url);
if (strpos($url, 'http') === false) {
$url = preg_replace('/^git@(github\.[^:]+):/', 'https://$1/', $url);
}
$url = preg_replace('/\.git$/', '', $url);
return sprintf('%s/compare/%s...%s', $url, urlencode($from), urlencode($to));
}

function formatCompareBitbucket($url, $from, $to) {
$url = preg_replace(['/\.git$/', '/^[email protected]:/'], ['', 'https://bitbucket.org/'], $url);
if (strpos($url, 'http') === false) {
$url = preg_replace('/^git@(bitbucket\.[^:]+):/', 'https://$1/', $url);
}
$url = preg_replace('/\.git$/', '', $url);
return sprintf('%s/branches/compare/%s%%0D%s', $url, urlencode($to), urlencode($from));
}

Expand Down

0 comments on commit 817bb8f

Please sign in to comment.