Skip to content

Commit

Permalink
[JENKINS-41124] Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Jan 21, 2017
1 parent ba727fa commit 32c5aba
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Expand Up @@ -203,7 +203,7 @@ public static abstract class BySCMSourceCriteria extends MultiBranchProjectFacto
* Defines how to decide whether or not a given repository should host our type of project.
*
* @param source a repository
* @return criteria for treating its branches as a match
* @return criteria for treating its branches as a match or ({@code null} if all branches match)
*/
@CheckForNull
protected abstract SCMSourceCriteria getSCMSourceCriteria(@NonNull SCMSource source);
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/jenkins/branch/NameEncoder.java
Expand Up @@ -24,9 +24,9 @@
package jenkins.branch;

/**
* Encodes names that are not nice so that they are safe to use as url path segments.
* Encodes names that are not nice so that they are safe to use as URL path segments.
* We don't want to do a full url encoding, only replace problematic names with {@code %} escaped variants so
* that when double encoded by Stapler etc we bypass issues.
* that when double encoded by Stapler etc. we bypass issues.
*
* @since 2.0.0
*/
Expand All @@ -44,7 +44,7 @@ public static String encode(String name) {
return "%00";
}
if (".".equals(name)) {
// just enough escaping to bypass the URL segment meaning of ".."
// just enough escaping to bypass the URL segment meaning of "."
return "%2E";
}
if ("..".equals(name)) {
Expand Down Expand Up @@ -104,7 +104,7 @@ public static String encode(String name) {
buf.append("%2F");
break;
case '?':
buf.append("%3F");
buf.append("%3F");
break;
case '[':
buf.append("%5B");
Expand All @@ -124,6 +124,9 @@ public static String encode(String name) {
}

public static String decode(String name) {
if (name.indexOf('%') == -1) {
return name;
}
if ("%00".equals(name)) {
return "";
}
Expand All @@ -133,9 +136,6 @@ public static String decode(String name) {
if ("%2E.".equals(name)) {
return "..";
}
if (name.indexOf('%') == -1) {
return name;
}
StringBuilder buf = new StringBuilder(name.length() + 16);
int matchIndex = 0;
char match = 0;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/integration/BrandingTest.java
Expand Up @@ -31,7 +31,6 @@
import hudson.model.ListView;
import hudson.model.Result;
import hudson.model.TopLevelItem;
import hudson.util.StreamTaskListener;
import hudson.views.JobColumn;
import hudson.views.StatusColumn;
import hudson.views.WeatherColumn;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/integration/MigrationTest.java
Expand Up @@ -232,7 +232,7 @@ public void nameMangling_folder_reload() throws Exception {
r.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
OrganizationFolder foo = (OrganizationFolder) r.j.jenkins.getItem("foo");
OrganizationFolder foo = r.j.jenkins.getItemByFullName("foo", OrganizationFolder.class);
foo.doReload();
assertDataMigrated(foo);
}
Expand All @@ -255,7 +255,7 @@ public void nameMangling_2_folder_reload() throws Exception {
r.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
OrganizationFolder foo = (OrganizationFolder) r.j.jenkins.getItem("foo");
OrganizationFolder foo = r.j.jenkins.getItemByFullName("foo", OrganizationFolder.class);
foo.doReload();
assertDataMigrated(foo);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/jenkins/branch/WorkspaceLocatorImplTest.java
Expand Up @@ -74,7 +74,7 @@ public void locate() throws Exception {
stuff.scheduleBuild2(0).getFuture().get();
r.waitUntilNoActivity();
showComputation(stuff);
FreeStyleProject master = r.jenkins.getItemByFullName("stuff/dev%2fflow", FreeStyleProject.class);
FreeStyleProject master = r.jenkins.getItemByFullName("stuff/dev%2Fflow", FreeStyleProject.class);
assertNotNull(master);
assertEquals(r.jenkins.getRootPath().child("workspace/stuff_dev_flow-L5GKER67QGVMJ2UD3JCSGKEV2ACON2O4VO4RNUZ27HGUY32SYVXQ"), r.jenkins.getWorkspaceFor(master));
DumbSlave slave = r.createOnlineSlave();
Expand Down

0 comments on commit 32c5aba

Please sign in to comment.