Skip to content

Commit

Permalink
[FIXED JENKINS-11070] handle $ in filenames.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Petti committed Sep 21, 2011
1 parent 3214252 commit 6471d3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/hudson/plugins/perforce/PerforceSCMHelper.java
Expand Up @@ -214,6 +214,7 @@ static public Pattern getTokenPattern(String str) {
regex = regex.replaceAll("([^\\.])\\.([^\\.])", "$1\\\\.$2");
regex = regex.replaceAll("\\.\\.\\.", "(.*)");
regex = regex.replaceAll("%%[0-9]", "([^/]*)");
regex = regex.replaceAll("\\$", Matcher.quoteReplacement("\\$"));
Pattern pattern = Pattern.compile(regex);
return pattern;
}
Expand Down Expand Up @@ -252,17 +253,17 @@ static public String doMapping(String lhs, String rhs, String orig) {
while(true){
Matcher match = Pattern.compile("\\.\\.\\.").matcher(mappedPath);
if(match.find()){
mappedPath = match.replaceFirst(tripleDotIterator.next());
mappedPath = match.replaceFirst( Matcher.quoteReplacement(tripleDotIterator.next()) );
continue;
}
match = Pattern.compile("\\*").matcher(mappedPath);
if(match.find()){
mappedPath = match.replaceFirst(asteriskIterator.next());
mappedPath = match.replaceFirst( Matcher.quoteReplacement(asteriskIterator.next()) );
continue;
}
match = Pattern.compile("%%([0-9])").matcher(mappedPath);
if(match.find()){
mappedPath = match.replaceFirst( numberedTokenMap.get(Integer.valueOf(match.group(1))) );
mappedPath = match.replaceFirst( Matcher.quoteReplacement(numberedTokenMap.get(Integer.valueOf(match.group(1)))) );
continue;
}
break;
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/hudson/plugins/perforce/PerforceSCMHelperTest.java
Expand Up @@ -127,6 +127,16 @@ public void testMappingImplementation() {
"//Install/.../*.xml",
"/home/jenkins/workspace/.../*.xml",
"//Install/trunk/test.xml"));
assertEquals("/home/jenkins/workspace/trunk/SomeClass$Sub.class",
PerforceSCMHelper.doMapping(
"//Install/.../*.class",
"/home/jenkins/workspace/.../*.class",
"//Install/trunk/SomeClass$Sub.class"));
assertEquals("/home/jenkins/workspace/trunk/SomeClass$Sub.class",
PerforceSCMHelper.doMapping(
"//Install/.../*$Sub.class",
"/home/jenkins/workspace/.../*$Sub.class",
"//Install/trunk/SomeClass$Sub.class"));
}

}

0 comments on commit 6471d3a

Please sign in to comment.