Skip to content

Commit

Permalink
Merge pull request #41 from boherm/ignore-dependabot-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
boherm authored Jun 3, 2024
2 parents 14b6335 + 5ad8eb5 commit 7ed48b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function __construct(

public function __invoke(WelcomeNewContributorCommand $command): void
{
// We ignore dependabot PRs.
if ('dependabot[bot]' === $command->contributor) {
return;
}

// We check if the committer is a new contributor.
if ($this->committerRepository->isNewContributor($command->repositoryOwner, $command->repositoryName, $command->contributor)) {
// If it is, we add a comment to the PR.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function setUp(): void
/**
* @dataProvider provideTestHandle
*/
public function testHandle(PullRequestId $pullRequestId, bool $newContributor, bool $expectedComment): void
public function testHandle(PullRequestId $pullRequestId, string $contributor, bool $newContributor, bool $expectedComment): void
{
$this->prRepository->feed([
PullRequest::create(
Expand All @@ -60,12 +60,12 @@ public function testHandle(PullRequestId $pullRequestId, bool $newContributor, b
repositoryOwner: $pullRequestId->repositoryOwner,
repositoryName: $pullRequestId->repositoryName,
pullRequestNumber: $pullRequestId->pullRequestNumber,
contributor: 'fakeContributor',
contributor: $contributor,
));
}

/**
* @return array<array<int, PullRequestId|bool>>
* @return array<array<int, PullRequestId|bool|string>>
*/
public static function provideTestHandle(): array
{
Expand All @@ -76,6 +76,7 @@ public static function provideTestHandle(): array
repositoryName: 'fake',
pullRequestNumber: 'fake'
),
'fakeContributor',
false,
false,
],
Expand All @@ -85,6 +86,7 @@ public static function provideTestHandle(): array
repositoryName: 'fake',
pullRequestNumber: 'fake'
),
'fakeContributor',
true,
true,
],
Expand All @@ -94,6 +96,7 @@ public static function provideTestHandle(): array
repositoryName: 'PrestaShop',
pullRequestNumber: 'pullRequestNumber'
),
'fakeContributor',
false,
false,
],
Expand All @@ -103,9 +106,20 @@ public static function provideTestHandle(): array
repositoryName: 'PrestaShop',
pullRequestNumber: 'pullRequestNumber'
),
'fakeContributor',
true,
true,
],
[
new PullRequestId(
repositoryOwner: 'PrestaShop',
repositoryName: 'PrestaShop',
pullRequestNumber: 'pullRequestNumber'
),
'dependabot[bot]',
true,
false,
],
];
}
}

0 comments on commit 7ed48b7

Please sign in to comment.