Documentation
¶
Overview ¶
Package internal contains miscellaneous functions and objects useful within Scalibr
Index ¶
- func GitignoreMatch(gitignores []GitignorePattern, filePath []string, isDir bool) bool
- func MatchNamedCaptureGroups(regEx *regexp.Regexp, content string) map[string]string
- func ParentDir(path string, n int) string
- func WalkDirUnsorted(fsys scalibrfs.FS, root string, fn fs.WalkDirFunc, postFN postWalkDirFunc) error
- type GitignorePattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GitignoreMatch ¶ added in v0.1.8
func GitignoreMatch(gitignores []GitignorePattern, filePath []string, isDir bool) bool
GitignoreMatch returns whether the specified file path should be ignored according to the specified .gitignore patterns.
func MatchNamedCaptureGroups ¶
MatchNamedCaptureGroups takes a regular expression and string and returns all of the named capture group results in a map. This is only for the first match in the regex. Callers shouldn't be providing regexes with multiple capture groups with the same name.
func ParentDir ¶
ParentDir returns the parent dir up to n dirs deep. If the path is below n dirs, the function returns path. This function assumes no leading `/` or drive letter.
func WalkDirUnsorted ¶
func WalkDirUnsorted(fsys scalibrfs.FS, root string, fn fs.WalkDirFunc, postFN postWalkDirFunc) error
WalkDirUnsorted walks the file tree rooted at root, calling fn for each file or directory in the tree, including root. It also calls postFN after the walk of the file or dir has finished, including the traversal of all sub-directories.
All errors that arise visiting files and directories are filtered by fn: see the fs.WalkDirFunc documentation for details.
WalkDirUnsorted does not follow symbolic links found in directories, but if root itself is a symbolic link, its target will be walked.
Types ¶
type GitignorePattern ¶ added in v0.1.8
GitignorePattern is a list of patterns found inside a .gitignore file.
func EmptyGitignore ¶ added in v0.2.0
func EmptyGitignore() GitignorePattern
EmptyGitignore returns an empty matcher that doesn't match on any pattern.
func ParseDirForGitignore ¶ added in v0.1.8
func ParseDirForGitignore(fs scalibrfs.FS, dirPath string) (GitignorePattern, error)
ParseDirForGitignore parses .gitignore patterns found in the specified directory.
func ParseParentGitignores ¶ added in v0.1.8
func ParseParentGitignores(fs scalibrfs.FS, dirPath string) ([]GitignorePattern, error)
ParseParentGitignores parses all .gitignore patterns between the current dir and the scan root, excluding the current directory.