class
Agate::Pathspec
- Agate::Pathspec
- Reference
- Object
Overview
A compiled pathspec for matching file paths against glob patterns.
ps = Pathspec.new("*.cr", "docs/**")
ps.matches?("src/main.cr") # => true
ps.matches?("README.md") # => false
# Match against a repository's working directory
matches = ps.match_workdir(repo)
matches.each { |path| puts path }
# Match against an index or tree
matches = ps.match_index(repo.index)
matches = ps.match_tree(tree)
Defined in:
agate/pathspec.crConstructors
-
.new(patterns : Array(String))
Compiles a pathspec from one or more glob patterns.
-
.new(*patterns : String)
Compiles a pathspec from one or more glob patterns.
Instance Method Summary
-
#match_diff(diff : Diff, flags : PathspecFlags = PathspecFlags::None) : MatchList
Matches this pathspec against entries in a diff.
-
#match_index(index : Index, flags : PathspecFlags = PathspecFlags::None) : MatchList
Matches this pathspec against entries in an index.
-
#match_tree(tree : Tree, flags : PathspecFlags = PathspecFlags::None) : MatchList
Matches this pathspec against files in a tree.
-
#match_workdir(repo : Repository, flags : PathspecFlags = PathspecFlags::None) : MatchList
Matches this pathspec against files in the working directory.
-
#matches?(path : String, flags : PathspecFlags = PathspecFlags::None) : Bool
Returns true if the path matches this pathspec.
Constructor Detail
Instance Method Detail
Matches this pathspec against entries in a diff.
Returns a MatchList (use diff_entries instead of entries
to access the matched deltas).
Matches this pathspec against entries in an index.
Returns a MatchList of matching filenames.
Matches this pathspec against files in a tree.
Returns a MatchList of matching filenames.
Matches this pathspec against files in the working directory.
Returns a MatchList of matching filenames.
Returns true if the path matches this pathspec.