Skip to content

Commit

Permalink
fix(AddTeamToCodeowners): skip file generation if team name invalid
Browse files Browse the repository at this point in the history
Closes #49
  • Loading branch information
sghill committed Sep 2, 2023
1 parent cb7d9f1 commit fdd92ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Tree visit(@Nullable Tree tree, ExecutionContext executionContext, Cursor

@Override
public Collection<? extends SourceFile> generate(Scanned acc, ExecutionContext ctx) {
if (acc.foundFile) {
if (acc.foundFile || !acc.hasValidTeamName()) {
return Collections.emptyList();
}
PlainTextParser parser = new PlainTextParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,29 @@ void shouldNoOpIfInvalidTeamGenerated() {
);
}

@Test
void shouldNoOpIfInvalidTeamGeneratedAndCodeownersFileAbsent() {
rewriteRun(
pomXml("""
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.72</version>
</parent>
<artifactId>tool-labels-plugin</artifactId>
<version>0.1</version>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
</project>
""")
);
}

@Test
void shouldNotModifyNonCodeowners() {
rewriteRun(
Expand Down

0 comments on commit fdd92ee

Please sign in to comment.