Skip to content

Commit d116081

Browse files
committed
frontend/dockerfile/dockerignore: touch-up godoc and code
Use "doc links" where possible, and better describe the function. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 01b25b1 commit d116081

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

frontend/dockerfile/dockerignore/dockerignore.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,29 @@ import (
1010
"github.com/pkg/errors"
1111
)
1212

13-
// ReadAll reads a .dockerignore file and returns the list of file patterns
14-
// to ignore. Note this will trim whitespace from each line as well
15-
// as use GO's "clean" func to get the shortest/cleanest path for each.
13+
// ReadAll reads an ignore file from a reader and returns the list of file
14+
// patterns to ignore, applying the following rules:
15+
//
16+
// - An UTF8 BOM header (if present) is stripped.
17+
// - Lines starting with "#" are considered comments and are skipped.
18+
//
19+
// For remaining lines:
20+
//
21+
// - Leading and trailing whitespace is removed from each ignore pattern.
22+
// - It uses [filepath.Clean] to get the shortest/cleanest path for
23+
// ignore patterns.
24+
// - Leading forward-slashes ("/") are removed from ignore patterns,
25+
// so "/some/path" and "some/path" are considered equivalent.
1626
func ReadAll(reader io.Reader) ([]string, error) {
1727
if reader == nil {
1828
return nil, nil
1929
}
2030

21-
scanner := bufio.NewScanner(reader)
2231
var excludes []string
2332
currentLine := 0
24-
2533
utf8bom := []byte{0xEF, 0xBB, 0xBF}
34+
35+
scanner := bufio.NewScanner(reader)
2636
for scanner.Scan() {
2737
scannedBytes := scanner.Bytes()
2838
// We trim UTF8 BOM

0 commit comments

Comments
 (0)