diff --git a/src/main/java/org/openrewrite/jenkins/github/AddTeamToCodeowners.java b/src/main/java/org/openrewrite/jenkins/github/AddTeamToCodeowners.java index cff1fb6..31968c8 100644 --- a/src/main/java/org/openrewrite/jenkins/github/AddTeamToCodeowners.java +++ b/src/main/java/org/openrewrite/jenkins/github/AddTeamToCodeowners.java @@ -80,7 +80,7 @@ public Tree visit(@Nullable Tree tree, ExecutionContext executionContext, Cursor @Override public Collection generate(Scanned acc, ExecutionContext ctx) { - if (acc.foundFile) { + if (acc.foundFile || !acc.hasValidTeamName()) { return Collections.emptyList(); } PlainTextParser parser = new PlainTextParser(); diff --git a/src/test/java/org/openrewrite/jenkins/github/AddTeamToCodeownersTest.java b/src/test/java/org/openrewrite/jenkins/github/AddTeamToCodeownersTest.java index a141dc3..7906b27 100644 --- a/src/test/java/org/openrewrite/jenkins/github/AddTeamToCodeownersTest.java +++ b/src/test/java/org/openrewrite/jenkins/github/AddTeamToCodeownersTest.java @@ -220,6 +220,29 @@ void shouldNoOpIfInvalidTeamGenerated() { ); } + @Test + void shouldNoOpIfInvalidTeamGeneratedAndCodeownersFileAbsent() { + rewriteRun( + pomXml(""" + + + org.jenkins-ci.plugins + plugin + 4.72 + + tool-labels-plugin + 0.1 + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + + + """) + ); + } + @Test void shouldNotModifyNonCodeowners() { rewriteRun(