Skip to content

Make GoLangMatchFileFilter work on Windows#103

Merged
marcuslinke merged 1 commit intodocker-java:masterfrom
albers:golangmatch-filefilter
Nov 26, 2014
Merged

Make GoLangMatchFileFilter work on Windows#103
marcuslinke merged 1 commit intodocker-java:masterfrom
albers:golangmatch-filefilter

Conversation

@albers
Copy link
Copy Markdown
Contributor

@albers albers commented Nov 26, 2014

GoLangMatchFileFilter uses a regular expression to strip the base dir part from the absolute path.
This fails on Windows because backslashes are not properly escaped (see commit message).
This PR replaces the substitution with a string operation.

Without this,
BuildImageCmdImplTest.testDockerBuilderAddFolder()
and BuildImageCmdImplTest.testDockerIgnore() both fail with

java.util.regex.PatternSyntaxException: Illegal/unsupported escape
sequence near index 3
D:\Eclipse\Jenkins\docker-java\target\test-classes\testDockerignore\a\
   ^
	at java.util.regex.Pattern.error(Pattern.java:1924)
	at java.util.regex.Pattern.escape(Pattern.java:2416)
	at java.util.regex.Pattern.atom(Pattern.java:2164)
	at java.util.regex.Pattern.sequence(Pattern.java:2097)
	at java.util.regex.Pattern.expr(Pattern.java:1964)
	at java.util.regex.Pattern.compile(Pattern.java:1665)
	at java.util.regex.Pattern.<init>(Pattern.java:1337)
	at java.util.regex.Pattern.compile(Pattern.java:1022)
	at java.lang.String.replaceFirst(String.java:2119)
	at
com.github.dockerjava.core.GoLangMatchFileFilter.accept(GoLangMatchFileFilter.java:26)
	at
org.apache.commons.io.filefilter.AndFileFilter.accept(AndFileFilter.java:122)
	at
org.apache.commons.io.filefilter.OrFileFilter.accept(OrFileFilter.java:118)
	at java.io.File.listFiles(File.java:1285)
marcuslinke added a commit that referenced this pull request Nov 26, 2014
Make GoLangMatchFileFilter work on Windows
@marcuslinke marcuslinke merged commit 02d3911 into docker-java:master Nov 26, 2014
@marcuslinke
Copy link
Copy Markdown
Contributor

@albers Thanks Harald!

@albers albers deleted the golangmatch-filefilter branch November 26, 2014 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants