(filesystem fs.Filesystem, file string, cd ChangeDetector, linesSeen map[string]struct{})
| 372 | } |
| 373 | |
| 374 | func loadParseIncludeFile(filesystem fs.Filesystem, file string, cd ChangeDetector, linesSeen map[string]struct{}) ([]Pattern, error) { |
| 375 | // Allow escaping the folders filesystem. |
| 376 | // TODO: Deprecate, somehow? |
| 377 | if filesystem.Type() == fs.FilesystemTypeBasic { |
| 378 | uri := filesystem.URI() |
| 379 | joined := filepath.Join(uri, file) |
| 380 | if !fs.IsParent(joined, uri) { |
| 381 | filesystem = fs.NewFilesystem(filesystem.Type(), filepath.Dir(joined)) |
| 382 | file = filepath.Base(joined) |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | if cd.Seen(filesystem, file) { |
| 387 | return nil, errors.New("multiple include") |
| 388 | } |
| 389 | |
| 390 | fd, info, err := loadIgnoreFile(filesystem, file) |
| 391 | if err != nil { |
| 392 | // isNotExist is considered "ok" in a sense of that a folder doesn't have to act |
| 393 | // upon it. This is because it is allowed for .stignore to not exist. However, |
| 394 | // included ignore files are not allowed to be missing and these errors should be |
| 395 | // acted upon on. So we don't preserve the error chain here and manually set an |
| 396 | // error instead, if the file is missing. |
| 397 | if fs.IsNotExist(err) { |
| 398 | err = errors.New("file not found") |
| 399 | } |
| 400 | return nil, err |
| 401 | } |
| 402 | defer fd.Close() |
| 403 | |
| 404 | cd.Remember(filesystem, file, info.ModTime()) |
| 405 | |
| 406 | _, patterns, err := parseIgnoreFile(filesystem, fd, file, cd, linesSeen) |
| 407 | return patterns, err |
| 408 | } |
| 409 | |
| 410 | func parseLine(line string) ([]Pattern, error) { |
| 411 | // We use native normalization internally, thus the patterns must match |
no test coverage detected