Skip to content
Permalink
Browse files

[JENKINS-27351] A parametrized branchspec that resolves to empty shou…

…ld match everything
  • Loading branch information...
jeanblanchard authored and MarkEWaite committed Mar 10, 2015
1 parent 9369a12 commit 3a83b2c181dd7bfb32e44c306b6360db8a83471c
@@ -113,7 +113,11 @@ public boolean matches(String ref, EnvVars env) {
}

private String getExpandedName(EnvVars env) {
return env.expand(name);
String expandedName = env.expand(name);
if (expandedName.length() == 0) {
return "**";
}
return expandedName;
}

private Pattern getPattern(EnvVars env) {
@@ -64,6 +64,7 @@ public void testMatchEnv() {
envMap.put("mybranch", "my.branch");
envMap.put("anyLong", "**");
envMap.put("anyShort", "*");
envMap.put("anyEmpty", "");
EnvVars env = new EnvVars(envMap);

BranchSpec l = new BranchSpec("${master}");
@@ -105,6 +106,12 @@ public void testMatchEnv() {

assertTrue(p.matches("origin/x", env));
assertFalse(p.matches("origin/my-branch/b1", env));

BranchSpec q = new BranchSpec("${anyEmpty}");

assertTrue(q.matches("origin/my.branch/b1", env));
assertTrue(q.matches("origin/my-branch/b1", env));
assertTrue(q.matches("remote/origin/my.branch/b1", env));
}

@Test

0 comments on commit 3a83b2c

Please sign in to comment.
You can’t perform that action at this time.