-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
93 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Api\PullRequest; | ||
|
||
use App\Model\Repository; | ||
use Github\Api\PullRequest; | ||
use Github\Api\Repo; | ||
|
||
/** | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
class GithubPullRequestApi implements PullRequestApi | ||
{ | ||
/** | ||
* @var Repo | ||
*/ | ||
private $github; | ||
private $botUsername; | ||
private $pullRequest; | ||
|
||
public function __construct(Repo $github, PullRequest $pullRequest, string $botUsername) | ||
{ | ||
$this->github = $github; | ||
$this->botUsername = $botUsername; | ||
$this->pullRequest = $pullRequest; | ||
} | ||
|
||
public function show(Repository $repository, $number): array | ||
{ | ||
return (array) $this->pullRequest->show($repository->getVendor(), $repository->getName(), $number); | ||
} | ||
|
||
/** | ||
* Trigger start of a "find reviewer" job. The job runs on github actions and will comment on the PR. | ||
*/ | ||
public function findReviewer(Repository $repository, $number, string $type) | ||
{ | ||
$this->github->dispatch($this->botUsername, 'carsonbot', 'find-reviewer', [ | ||
'repository' => $repository->getFullName(), | ||
'pull_request_number' => $number, | ||
'type' => $type, | ||
]); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Api\PullRequest; | ||
|
||
use App\Model\Repository; | ||
|
||
/** | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
class NullPullRequestApi implements PullRequestApi | ||
{ | ||
public function show(Repository $repository, $number): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function findReviewer(Repository $repository, $number, string $type) | ||
{ | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Api\PullRequest; | ||
|
||
use App\Model\Repository; | ||
|
||
/** | ||
* Actions that are specific to pull requests. | ||
* Actions like comment/close can be performed using the IssueApi. | ||
* | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
interface PullRequestApi | ||
{ | ||
public function show(Repository $repository, $number): array; | ||
|
||
public function findReviewer(Repository $repository, $number, string $type); | ||
} |