diff --git a/src/Struct/Github/PullRequest.php b/src/Struct/Github/PullRequest.php index 842158b..2c8f2f0 100644 --- a/src/Struct/Github/PullRequest.php +++ b/src/Struct/Github/PullRequest.php @@ -31,6 +31,11 @@ class PullRequest extends \Danger\Struct\PullRequest */ private ?CommentCollection $comments = null; + /** + * @var list + */ + public array $rawFiles = []; + public function __construct(private GithubClient $client, private string $owner, private string $repo, private string $headSha) { } @@ -71,7 +76,9 @@ public function getFiles(): FileCollection return $this->files; } - $this->rawFiles = $this->client->pullRequest()->files($this->owner, $this->repo, $this->id); + $this->rawFiles = (new ResultPager($this->client)) + ->fetch($this->client->pullRequest(), 'files', [$this->owner, $this->repo, $this->id]) + ; $collection = new FileCollection(); diff --git a/src/Struct/Gitlab/PullRequest.php b/src/Struct/Gitlab/PullRequest.php index b1b0d84..aa8bf04 100644 --- a/src/Struct/Gitlab/PullRequest.php +++ b/src/Struct/Gitlab/PullRequest.php @@ -31,6 +31,11 @@ class PullRequest extends \Danger\Struct\PullRequest */ private ?CommentCollection $comments = null; + /** + * @var array{'changes': array{'new_path': string, 'diff'?: string, 'new_file': bool, 'deleted_file': bool}[]} + */ + public array $rawFiles = ['changes' => []]; + public function __construct(private Client $client, private string $latestSha) { } diff --git a/src/Struct/PullRequest.php b/src/Struct/PullRequest.php index e88e28a..bce9043 100644 --- a/src/Struct/PullRequest.php +++ b/src/Struct/PullRequest.php @@ -37,11 +37,6 @@ abstract class PullRequest */ public array $rawCommits = []; - /** - * @var array{'changes': array{'new_path': string, 'diff'?: string, 'new_file': bool, 'deleted_file': bool}[]} - */ - public array $rawFiles = ['changes' => []]; - /** * @return CommitCollection */ diff --git a/tests/Command/GithubCommandTest.php b/tests/Command/GithubCommandTest.php index 7967357..3034618 100644 --- a/tests/Command/GithubCommandTest.php +++ b/tests/Command/GithubCommandTest.php @@ -18,19 +18,6 @@ */ class GithubCommandTest extends TestCase { - /** - * @return array[] - */ - public static function invalidUrls(): array - { - return [ - ['https://github.com'], - ['testhttps://github.com'], - ['testhttps://github.com/shyim/danger-php'], - ['https://gitlab.com'], - ]; - } - /** * @dataProvider invalidUrls */ @@ -44,6 +31,19 @@ public function testInvalidUrl(string $url): void $cmd->run(new ArgvInput(['danger', $url]), new NullOutput()); } + /** + * @return array[] + */ + public static function invalidUrls(): array + { + return [ + ['https://github.com'], + ['testhttps://github.com'], + ['testhttps://github.com/shyim/danger-php'], + ['https://gitlab.com'], + ]; + } + public function testInvalidConfig(): void { $cmd = new GithubCommand($this->createMock(Github::class), new ConfigLoader(), new Runner());