From e6d18c5fe929a3f67c00d9c62553e0c76f429c50 Mon Sep 17 00:00:00 2001
From: Tim Jacomb
Date: Tue, 5 Nov 2024 22:05:25 +0000
Subject: [PATCH] [JENKINS-74811] Allow reverting the pull request title change
---
.../MultiBranchProjectDisplayNamingStrategy.java | 10 ++++++++++
src/main/resources/jenkins/branch/Messages.properties | 2 +-
.../help-displayNamingStrategy.html | 9 +++++++++
.../java/jenkins/branch/ProjectNamingStrategyTest.java | 6 ++++++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/src/main/java/jenkins/branch/MultiBranchProjectDisplayNamingStrategy.java b/src/main/java/jenkins/branch/MultiBranchProjectDisplayNamingStrategy.java
index a08c25e7..9106da61 100644
--- a/src/main/java/jenkins/branch/MultiBranchProjectDisplayNamingStrategy.java
+++ b/src/main/java/jenkins/branch/MultiBranchProjectDisplayNamingStrategy.java
@@ -70,6 +70,16 @@ public String generateName(@NonNull final String rawName, final String displayNa
return format("%s (%s)", displayName, cleanedUpBranchName);
}
},
+ /**
+ * Use the raw name.
+ */
+ RAW(true, Messages._MultiBranchProjectDisplayNamingTrait_Raw()) {
+ @Override
+ public String generateName(@NonNull final String rawName, final String displayName) {
+ return rawName;
+ }
+ },
+
;
private final boolean needsObjectDisplayName;
diff --git a/src/main/resources/jenkins/branch/Messages.properties b/src/main/resources/jenkins/branch/Messages.properties
index a8bcb980..2aee3dd2 100644
--- a/src/main/resources/jenkins/branch/Messages.properties
+++ b/src/main/resources/jenkins/branch/Messages.properties
@@ -49,7 +49,7 @@ RateLimitBranchProperty.duration.year=Year
MultiBranchProject.BranchIndexing.displayName=Scan {0}
MultiBranchProject.CopyItemVeto.reason=Copying branch projects outside of their multi-branch container is not supported.
MultiBranchProjectDisplayNamingTrait.DisplayName=Job display name with fallback to name
-MultiBranchProjectDisplayNamingTrait.Raw=Name only
+MultiBranchProjectDisplayNamingTrait.Raw=Simple name only
MultiBranchProjectDisplayNamingTrait.RawAndDisplayName=Name and, if available, display name
MultiBranchProjectDisplayNamingTrait.TraitDisplayName=Job display name strategy
OrganizationFolder.OrganizationScan.displayName=Scan {0}
diff --git a/src/main/resources/jenkins/branch/MultiBranchProjectDisplayNamingTrait/help-displayNamingStrategy.html b/src/main/resources/jenkins/branch/MultiBranchProjectDisplayNamingTrait/help-displayNamingStrategy.html
index 1318f80b..cd2df56e 100644
--- a/src/main/resources/jenkins/branch/MultiBranchProjectDisplayNamingTrait/help-displayNamingStrategy.html
+++ b/src/main/resources/jenkins/branch/MultiBranchProjectDisplayNamingTrait/help-displayNamingStrategy.html
@@ -19,5 +19,14 @@
Value for configuration-as-code: RAW_AND_OBJECT_DISPLAY_NAME
+
+
+ Simple name:
+
+ Just the raw name
+
+ Value for configuration-as-code: RAW
+
+
diff --git a/src/test/java/jenkins/branch/ProjectNamingStrategyTest.java b/src/test/java/jenkins/branch/ProjectNamingStrategyTest.java
index 3eca33bb..bfd4298b 100644
--- a/src/test/java/jenkins/branch/ProjectNamingStrategyTest.java
+++ b/src/test/java/jenkins/branch/ProjectNamingStrategyTest.java
@@ -34,6 +34,12 @@ public void testCompositeStrategy() throws Exception {
testNamingStrategy(MultiBranchProjectDisplayNamingStrategy.RAW_AND_OBJECT_DISPLAY_NAME);
}
+ @Test
+ @Issue("JENKINS-74811")
+ public void testRawStrategy() throws Exception {
+ testNamingStrategy(MultiBranchProjectDisplayNamingStrategy.RAW);
+ }
+
@Test
@Issue("JENKINS-55348")
public void testObjectNameStrategy() throws Exception {