Merge pull request #315 from thaJeztah/17.09-backport-dont-warn-for-comment-only-lines
[17.09] Warn on empty continuation lines only, not for comments
This commit is contained in:
@@ -290,6 +290,10 @@ func Parse(rwc io.Reader) (*Result, error) {
|
||||
}
|
||||
currentLine++
|
||||
|
||||
if isComment(scanner.Bytes()) {
|
||||
// original line was a comment (processLine strips comments)
|
||||
continue
|
||||
}
|
||||
if isEmptyContinuationLine(bytesRead) {
|
||||
hasEmptyContinuationLine = true
|
||||
continue
|
||||
@@ -331,8 +335,12 @@ func trimWhitespace(src []byte) []byte {
|
||||
return bytes.TrimLeftFunc(src, unicode.IsSpace)
|
||||
}
|
||||
|
||||
func isComment(line []byte) bool {
|
||||
return tokenComment.Match(trimWhitespace(line))
|
||||
}
|
||||
|
||||
func isEmptyContinuationLine(line []byte) bool {
|
||||
return len(trimComments(trimWhitespace(line))) == 0
|
||||
return len(trimWhitespace(line)) == 0
|
||||
}
|
||||
|
||||
var utf8bom = []byte{0xEF, 0xBB, 0xBF}
|
||||
|
||||
@@ -141,6 +141,13 @@ RUN something \
|
||||
RUN another \
|
||||
|
||||
thing
|
||||
RUN non-indented \
|
||||
# this is a comment
|
||||
after-comment
|
||||
|
||||
RUN indented \
|
||||
# this is an indented comment
|
||||
comment
|
||||
`)
|
||||
|
||||
result, err := Parse(dockerfile)
|
||||
|
||||
Reference in New Issue
Block a user