-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from boherm/add-check-table-description-and-mi…
…lestone-missing-comment
- Loading branch information
Showing
22 changed files
with
1,589 additions
and
41 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,13 @@ | ||
framework: | ||
validation: | ||
email_validation_mode: html5 | ||
|
||
# Enables validator auto-mapping support. | ||
# For instance, basic validation constraints will be inferred from Doctrine's metadata. | ||
#auto_mapping: | ||
# App\Entity\: [] | ||
|
||
when@test: | ||
framework: | ||
validation: | ||
not_compromised_password: false |
15 changes: 15 additions & 0 deletions
15
src/PullRequest/Application/Command/CheckMilestoneCommand.php
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\PullRequest\Application\Command; | ||
|
||
class CheckMilestoneCommand | ||
{ | ||
public function __construct( | ||
public readonly string $repositoryOwner, | ||
public readonly string $repositoryName, | ||
public readonly string $pullRequestNumber, | ||
) { | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/PullRequest/Application/Command/CheckTableDescriptionCommand.php
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\PullRequest\Application\Command; | ||
|
||
class CheckTableDescriptionCommand | ||
{ | ||
public function __construct( | ||
public readonly string $repositoryOwner, | ||
public readonly string $repositoryName, | ||
public readonly string $pullRequestNumber, | ||
) { | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/PullRequest/Application/CommandHandler/CheckMilestoneCommandHandler.php
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\PullRequest\Application\CommandHandler; | ||
|
||
use App\PullRequest\Application\Command\CheckMilestoneCommand; | ||
use App\PullRequest\Domain\Aggregate\PullRequest\PullRequestId; | ||
use App\PullRequest\Domain\Exception\PullRequestNotFoundException; | ||
use App\PullRequest\Domain\Gateway\PullRequestRepositoryInterface; | ||
|
||
class CheckMilestoneCommandHandler | ||
{ | ||
public function __construct( | ||
private readonly PullRequestRepositoryInterface $prRepository | ||
) { | ||
} | ||
|
||
public function __invoke(CheckMilestoneCommand $command): void | ||
{ | ||
// This command is only for PrestaShop/PrestaShop repository | ||
if ('PrestaShop' !== $command->repositoryOwner || 'PrestaShop' !== $command->repositoryName) { | ||
return; | ||
} | ||
|
||
// Retrieve the PullRequest object | ||
$prId = new PullRequestId($command->repositoryOwner, $command->repositoryName, $command->pullRequestNumber); | ||
$pullRequest = $this->prRepository->find($prId); | ||
if (null === $pullRequest) { | ||
throw new PullRequestNotFoundException(); | ||
} | ||
|
||
// We check if the milestone is set | ||
if (null === $pullRequest->getMilestoneNumber() && $pullRequest->isQAValidated()) { | ||
$this->prRepository->addMissingMilestoneComment($prId); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/PullRequest/Application/CommandHandler/CheckTableDescriptionCommandHandler.php
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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\PullRequest\Application\CommandHandler; | ||
|
||
use App\PullRequest\Application\Command\CheckTableDescriptionCommand; | ||
use App\PullRequest\Domain\Aggregate\PullRequest\PullRequestDescription; | ||
use App\PullRequest\Domain\Aggregate\PullRequest\PullRequestId; | ||
use App\PullRequest\Domain\Exception\PullRequestNotFoundException; | ||
use App\PullRequest\Domain\Gateway\PullRequestRepositoryInterface; | ||
use Symfony\Component\Validator\Validator\ValidatorInterface; | ||
|
||
class CheckTableDescriptionCommandHandler | ||
{ | ||
public function __construct( | ||
private readonly PullRequestRepositoryInterface $prRepository, | ||
private readonly ValidatorInterface $validator, | ||
) { | ||
} | ||
|
||
public function __invoke(CheckTableDescriptionCommand $command): void | ||
{ | ||
// This command is only for PrestaShop/PrestaShop repository | ||
if ('PrestaShop' !== $command->repositoryOwner || 'PrestaShop' !== $command->repositoryName) { | ||
return; | ||
} | ||
|
||
// Retrieve the PullRequest object | ||
$prId = new PullRequestId($command->repositoryOwner, $command->repositoryName, $command->pullRequestNumber); | ||
$pullRequest = $this->prRepository->find($prId); | ||
if (null === $pullRequest) { | ||
throw new PullRequestNotFoundException(); | ||
} | ||
|
||
// Create PulLRequestDescription object with the description | ||
$prDescription = new PullRequestDescription($pullRequest->getBodyDescription()); | ||
|
||
// We check the description with the validator | ||
$errors = $this->validator->validate($prDescription); | ||
|
||
// If we have some errors, we need to add (or edit) the comment about this errors | ||
if (count($errors) > 0 || $prDescription->isLinkedIssuesNeeded()) { | ||
$this->prRepository->addTableDescriptionErrorsComment($prId, $errors, $prDescription->isLinkedIssuesNeeded()); | ||
} else { | ||
$this->prRepository->removeTableDescriptionErrorsComment($prId); | ||
} | ||
|
||
// Then, we had the labels to the PR by PullRequestDescription object | ||
$pullRequest->addLabelsByDescription($prDescription); | ||
$this->prRepository->update($pullRequest); | ||
} | ||
} |
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
Oops, something went wrong.