Skip to content

Commit 092271a

Browse files
committed
Fix rule "@mr-linter/has_any_labels" on empty labels
1 parent cb205ae commit 092271a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Application/Rule/Rules/HasAnyLabelsRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ final class HasAnyLabelsRule extends AbstractLabelsRule
1414

1515
protected function doLint(MergeRequest $request): bool
1616
{
17+
if ($this->labels->isEmpty()) {
18+
return ! $request->labels->isEmpty();
19+
}
20+
1721
return ! $this->labels->diff($request->labels)->equalsCount($this->labels);
1822
}
1923

tests/Unit/Application/Rule/Rules/HasAnyLabelsRuleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function providerForTestLint(): array
3535
['Feature', 'Backend'],
3636
'hasNotes' => false,
3737
],
38+
[
39+
$this->makeMergeRequest([
40+
'labels' => [
41+
'Feature',
42+
],
43+
]),
44+
[],
45+
'hasNotes' => false,
46+
],
3847
];
3948
}
4049

0 commit comments

Comments
 (0)