Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip CODEOWNERS generation for invalid teams #50

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
)
);
}
}