diff options
author | Yong Tang <yong.tang.github@outlook.com> | 2016-06-01 15:20:54 -0700 |
---|---|---|
committer | Yong Tang <yong.tang.github@outlook.com> | 2016-06-02 19:06:52 -0700 |
commit | 8913dace341c8fc9f9a3ab9518c8521c161b307f (patch) | |
tree | 615b02a4b141fb0ca3c7f3ce1cfca2e76ddce8e8 /builder/dockerignore | |
parent | 98c245c9e63793cf8ca03c5500e0820447c1861c (diff) | |
download | docker-8913dace341c8fc9f9a3ab9518c8521c161b307f.tar.gz |
Add support for comment in .dockerignore
This fix tries to address the issue raised in #20083 where
comment is not supported in `.dockerignore`.
This fix updated the processing of `.dockerignore` so that any
lines starting with `#` are ignored, which is similiar to the
behavior of `.gitignore`.
Related documentation has been updated.
Additional tests have been added to cover the changes.
This fix fixes #20083.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'builder/dockerignore')
-rw-r--r-- | builder/dockerignore/dockerignore.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/builder/dockerignore/dockerignore.go b/builder/dockerignore/dockerignore.go index 1fed3199af..4e09b05b0a 100644 --- a/builder/dockerignore/dockerignore.go +++ b/builder/dockerignore/dockerignore.go @@ -20,7 +20,12 @@ func ReadAll(reader io.ReadCloser) ([]string, error) { var excludes []string for scanner.Scan() { - pattern := strings.TrimSpace(scanner.Text()) + // Lines starting with # (comments) are ignored before processing + pattern := scanner.Text() + if strings.HasPrefix(pattern, "#") { + continue + } + pattern = strings.TrimSpace(pattern) if pattern == "" { continue } |