Skip to content

Commit

Permalink
Merge pull request #50 from openrewrite/fix/codeowners
Browse files Browse the repository at this point in the history
  • Loading branch information
sghill authored Sep 2, 2023
2 parents 1a12b66 + fdd92ee commit 94d6a49
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
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 @@ -61,8 +61,8 @@ void shouldAddFileIfMissing() {
pomXml(POM),
text(null,
"""
* @jenkinsci/sample-plugin-developers
""",
* @jenkinsci/sample-plugin-developers
""",
s -> s.path(".github/CODEOWNERS").noTrim()
)
);
Expand All @@ -78,15 +78,15 @@ void shouldAddLineIfTeamNotDefinedForAllRetainingTrailingSpace() {
* @global-owner1 @global-owner2
*.js @js-owner #This is an inline comment.
/build/logs/ @doctocat
""",
"""
# This is a comment.
* @jenkinsci/sample-plugin-developers
* @global-owner1 @global-owner2
*.js @js-owner #This is an inline comment.
/build/logs/ @doctocat
""",
s -> s.path(".github/CODEOWNERS").noTrim()
)
Expand Down Expand Up @@ -220,16 +220,39 @@ 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(
pomXml(POM),
text("*.iml",
s -> s.path(".gitignore")),
text(
"* @jenkinsci/sample-plugin-developers",
s -> s.path(".github/CODEOWNERS").noTrim()
)
pomXml(POM),
text("*.iml",
s -> s.path(".gitignore")),
text(
"* @jenkinsci/sample-plugin-developers",
s -> s.path(".github/CODEOWNERS").noTrim()
)
);
}
}

0 comments on commit 94d6a49

Please sign in to comment.