Skip to content

Commit

Permalink
github patch factory: support another URL format
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed May 24, 2024
1 parent c44fd73 commit 2c0739f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions entities/GitHub/GitHubPatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ static function construct($url, \Repository $repository) {
if ($src_branch != $repository->defaultBranch())
throw new \ValidationException("Patch is not against default branch");
}
elseif (preg_match('@^https://github.com/([^/]+/[^/]+)/compare/([^:]+):([^:]+):(.+)$@', $url, $m)) {
$src_repo = $m[1]; // user/repo
$org = $m[2];
$repo = $m[3];
$branch = $m[4];

if ($src_repo != $repository->name())
throw new \ValidationException("Patch is not for Project's repository");
}
elseif (preg_match('@^https://github.com/([^/]+)/([^/]+)/tree/(.+)$@', $url, $m)) {
$org = $m[1];
$repo = $m[2];
Expand Down

0 comments on commit 2c0739f

Please sign in to comment.