From d89dfcb8f7245b374442a3e78edcb14120bab1cf Mon Sep 17 00:00:00 2001 From: Steve Hill Date: Tue, 22 Aug 2023 21:29:46 -0700 Subject: [PATCH] fix: trim -plugin suffix from artifactId Avoids doubling up -plugin-plugin-developers team name Ref: #19 --- .../jenkins/github/ArtifactIdTeamNameGenerator.java | 2 +- .../jenkins/github/ArtifactIdTeamNameGeneratorTest.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGenerator.java b/src/main/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGenerator.java index fb646bb..5c1bffd 100644 --- a/src/main/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGenerator.java +++ b/src/main/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGenerator.java @@ -23,7 +23,7 @@ class ArtifactIdTeamNameGenerator implements TeamNameGenerator { public String generate(TeamNameInput input) { String artifactId = input.getArtifactId(); String withoutParent = artifactId; - if (artifactId.endsWith("-parent")) { + if (artifactId.endsWith("-parent") || artifactId.endsWith("-plugin")) { withoutParent = artifactId.substring(0, artifactId.lastIndexOf('-')); } return ("@jenkinsci/" + (withoutParent + "-plugin-developers")).toLowerCase(Locale.ROOT); diff --git a/src/test/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGeneratorTest.java b/src/test/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGeneratorTest.java index de3815d..e41ffc5 100644 --- a/src/test/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGeneratorTest.java +++ b/src/test/java/org/openrewrite/jenkins/github/ArtifactIdTeamNameGeneratorTest.java @@ -29,6 +29,10 @@ class ArtifactIdTeamNameGeneratorTest { "stashNotifier,@jenkinsci/stashnotifier-plugin-developers", "aws-java-sdk-parent,@jenkinsci/aws-java-sdk-plugin-developers", "warnings-ng-parent,@jenkinsci/warnings-ng-plugin-developers", + "build-user-vars-plugin,@jenkinsci/build-user-vars-plugin-developers", + "project-stats-plugin,@jenkinsci/project-stats-plugin-developers", + "plugin-usage-plugin,@jenkinsci/plugin-usage-plugin-developers", + "build-keeper-plugin,@jenkinsci/build-keeper-plugin-developers", }) void shouldGenerateExpectedTeamName(String artifactId, String expected) { String actual = generator.generate(new TeamNameInput(artifactId));