-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve github, bitbucket url matchers, php 5.3 compat
- Loading branch information
1 parent
fdc0002
commit 817bb8f
Showing
1 changed file
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) { | ||
|
@@ -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)); | ||
} | ||
|
||
|