Skip to content

Commit

Permalink
NEXT-31614 - Add rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pweyck committed Nov 10, 2023
1 parent 157f69c commit f3f9c42
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .danger.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,34 @@ function (Context $context): void {
},
]
))
/**
* MRs that target a release branch that is not trunk should have a thread with link to a trunk MR
* to disable this rule you can add the no-trunk label
*/
->useRule(new Condition(
function (Context $context) {
$labels = array_map('strtolower', $context->platform->pullRequest->labels);

return $context->platform instanceof Gitlab
&& !\in_array('no-trunk', $labels, true)
&& preg_match('/^6\.\d+.*/', $context->platform->raw['target_branch']);
},
[
function (Context $context): void {
$found = false;
foreach ($context->platform->pullRequest->getComments() as $comment) {
if (str_contains($comment->body, '/shopware/6/product/platform/-/merge_requests/')) {
$found = true;
break;
}
}

if (!$found) {
$context->failure('This MR should have a dependency on a trunk MR. Please add a thread with a link');
}
}
]
))
->useRule(new Condition(
function (Context $context) {
$labels = array_map('strtolower', $context->platform->pullRequest->labels);
Expand Down

0 comments on commit f3f9c42

Please sign in to comment.