Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Struct/Github/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class PullRequest extends \Danger\Struct\PullRequest
*/
private ?CommentCollection $comments = null;

/**
* @var list<array{filename: string, status: string, additions: int, deletions: int, changes: int, patch: string}>
*/
public array $rawFiles = [];

public function __construct(private GithubClient $client, private string $owner, private string $repo, private string $headSha)
{
}
Expand Down Expand Up @@ -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();

Expand Down
5 changes: 5 additions & 0 deletions src/Struct/Gitlab/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}
Expand Down
5 changes: 0 additions & 5 deletions src/Struct/PullRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => []];
Comment thread
shyim marked this conversation as resolved.

/**
* @return CommitCollection<Commit>
*/
Expand Down
26 changes: 13 additions & 13 deletions tests/Command/GithubCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@
*/
class GithubCommandTest extends TestCase
{
/**
* @return array<int, string>[]
*/
public static function invalidUrls(): array
{
return [
['https://github.com'],
['testhttps://github.com'],
['testhttps://github.com/shyim/danger-php'],
['https://gitlab.com'],
];
}

/**
* @dataProvider invalidUrls
*/
Expand All @@ -44,6 +31,19 @@ public function testInvalidUrl(string $url): void
$cmd->run(new ArgvInput(['danger', $url]), new NullOutput());
}

/**
* @return array<int, string>[]
*/
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());
Expand Down
Loading