Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding a comment if issue are needed for this PR and issues already linked to it #42

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __invoke(CheckTableDescriptionCommand $command): void
$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()) {
if (count($errors) > 0 || ($prDescription->isLinkedIssuesNeeded() && !$prDescription->hasLinkedIssues())) {
$this->prRepository->addTableDescriptionErrorsComment($prId, $errors, $prDescription->isLinkedIssuesNeeded());
} else {
$this->prRepository->removeTableDescriptionErrorsComment($prId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public function getIssuesFixed(): array
return array_pop($matches);
}

public function hasLinkedIssues(): bool
{
return !empty($this->getIssuesFixed());
}

/**
* @return string[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,29 @@ public static function provideTestHandle(): array
true,
['Feature'],
],
[
new PullRequestId(
repositoryOwner: 'PrestaShop',
repositoryName: 'PrestaShop',
pullRequestNumber: 'fake'
),
'
| Branch? | develop
| Description? | Fake description
| Type? | new feature
| Category? | FO
| BC breaks? | no
| Deprecations? | no
| How to test? | Fake how to test
| UI Tests | Fake UI tests
| Fixed issue or discussion? | Fixes #123
',
[],
[],
true,
false,
['develop', 'Feature'],
],
];
}

Expand Down
Loading