Skip to content

Commit c3f3898

Browse files
committed
Check to see if idealNames workaround can be removed
1 parent 43d8bbd commit c3f3898

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
<type>pom</type>
8686
<scope>import</scope>
8787
</dependency>
88+
<!-- TODO until in BOM -->
89+
<dependency>
90+
<groupId>org.jenkins-ci.plugins</groupId>
91+
<artifactId>cloudbees-folder</artifactId>
92+
<!-- TODO https://github.com/jenkinsci/cloudbees-folder-plugin/pull/479 -->
93+
<version>6.1004.v4c36007200f4</version>
94+
</dependency>
8895
</dependencies>
8996
</dependencyManagement>
9097
<dependencies>

src/main/java/jenkins/branch/MultiBranchProject.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,21 +2092,16 @@ private void observeExisting(@NonNull SCMHead head, @NonNull SCMRevision revisio
20922092
}
20932093

20942094
private void observeNew(@NonNull SCMHead head, @NonNull SCMRevision revision, @NonNull Branch branch, String rawName, String encodedName, Action[] revisionActions) {
2095-
P project;
20962095
if (!observer.mayCreate(encodedName)) {
20972096
listener.getLogger().println("Ignoring duplicate branch project " + rawName);
20982097
return;
20992098
}
2100-
try (ChildNameGenerator.Trace trace = ChildNameGenerator.beforeCreateItem(
2101-
MultiBranchProject.this, encodedName, branch.getName()
2102-
)) {
2103-
if (getItem(encodedName) != null) {
2104-
throw new IllegalStateException(
2105-
"JENKINS-42511: attempted to redundantly create " + encodedName + " in "
2106-
+ MultiBranchProject.this);
2107-
}
2108-
project = _factory.newInstance(branch);
2099+
if (getItem(encodedName) != null) {
2100+
throw new IllegalStateException(
2101+
"JENKINS-42511: attempted to redundantly create " + encodedName + " in "
2102+
+ MultiBranchProject.this);
21092103
}
2104+
P project = _factory.newInstance(branch);
21102105
if (!project.getName().equals(encodedName)) {
21112106
throw new IllegalStateException(
21122107
"Name of created project " + project + " did not match expected " + encodedName);

src/main/java/jenkins/branch/MultiBranchProjectDescriptor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ public String itemNameFromItem(@NonNull MultiBranchProject<P,R> parent, @NonNull
231231
if (factory.isProject(item)) {
232232
return NameEncoder.encode(factory.getBranch(item).getName());
233233
}
234-
String idealName = idealNameFromItem(parent, item);
235-
if (idealName != null) {
236-
return NameEncoder.encode(idealName);
234+
String name = item.getName();
235+
if (name != null) {
236+
return NameEncoder.encode(name);
237237
}
238238
return null;
239239
}
@@ -245,9 +245,9 @@ public String dirNameFromItem(@NonNull MultiBranchProject<P,R> parent, @NonNull
245245
if (factory.isProject(item)) {
246246
return NameMangler.apply(factory.getBranch(item).getName());
247247
}
248-
String idealName = idealNameFromItem(parent, item);
249-
if (idealName != null) {
250-
return NameMangler.apply(idealName);
248+
String name = item.getName();
249+
if (name != null) {
250+
return NameMangler.apply(name);
251251
}
252252
return null;
253253
}

src/main/java/jenkins/branch/OrganizationFolder.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,9 @@ public String itemNameFromItem(@NonNull OrganizationFolder parent, @NonNull Mult
852852
if (property != null) {
853853
return NameEncoder.encode(property.getName());
854854
}
855-
String idealName = idealNameFromItem(parent, item);
856-
if (idealName != null) {
857-
return NameEncoder.encode(idealName);
855+
String name = item.getName();
856+
if (name != null) {
857+
return NameEncoder.encode(name);
858858
}
859859
return null;
860860
}
@@ -866,9 +866,9 @@ public String dirNameFromItem(@NonNull OrganizationFolder parent, @NonNull Multi
866866
if (property != null) {
867867
return NameMangler.apply(property.getName());
868868
}
869-
String idealName = idealNameFromItem(parent, item);
870-
if (idealName != null) {
871-
return NameMangler.apply(idealName);
869+
String name = item.getName();
870+
if (name != null) {
871+
return NameMangler.apply(name);
872872
}
873873
return null;
874874
}
@@ -1436,19 +1436,14 @@ private void completeNew(MultiBranchProjectFactory factory, Map<String, Object>
14361436
.println("Ignoring duplicate child " + projectName + " named " + folderName);
14371437
return;
14381438
}
1439-
MultiBranchProject<?, ?> project;
1440-
try (ChildNameGenerator.Trace trace = ChildNameGenerator.beforeCreateItem(
1441-
OrganizationFolder.this, folderName, projectName
1442-
)) {
1443-
if (getItem(folderName) != null) {
1444-
throw new IllegalStateException(
1445-
"JENKINS-42511: attempted to redundantly create " + folderName + " in "
1446-
+ OrganizationFolder.this);
1447-
}
1448-
project = factory.createNewProject(
1449-
OrganizationFolder.this, folderName, sources, attributes, listener
1450-
);
1439+
if (getItem(folderName) != null) {
1440+
throw new IllegalStateException(
1441+
"JENKINS-42511: attempted to redundantly create " + folderName + " in "
1442+
+ OrganizationFolder.this);
14511443
}
1444+
MultiBranchProject<?, ?> project = factory.createNewProject(
1445+
OrganizationFolder.this, folderName, sources, attributes, listener
1446+
);
14521447
BulkChange bc = new BulkChange(project);
14531448
try {
14541449
if (!projectName.equals(folderName)) {

0 commit comments

Comments
 (0)