class Agate::Pathspec

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(patterns : Array(String)) #

Compiles a pathspec from one or more glob patterns.


[View source]
def self.new(*patterns : String) #

Compiles a pathspec from one or more glob patterns.


[View source]

Instance Method Detail

def match_diff(diff : Diff, flags : PathspecFlags = PathspecFlags::None) : MatchList #

Matches this pathspec against entries in a diff. Returns a MatchList (use diff_entries instead of entries to access the matched deltas).


[View source]
def match_index(index : Index, flags : PathspecFlags = PathspecFlags::None) : MatchList #

Matches this pathspec against entries in an index. Returns a MatchList of matching filenames.


[View source]
def match_tree(tree : Tree, flags : PathspecFlags = PathspecFlags::None) : MatchList #

Matches this pathspec against files in a tree. Returns a MatchList of matching filenames.


[View source]
def match_workdir(repo : Repository, flags : PathspecFlags = PathspecFlags::None) : MatchList #

Matches this pathspec against files in the working directory. Returns a MatchList of matching filenames.


[View source]
def matches?(path : String, flags : PathspecFlags = PathspecFlags::None) : Bool #

Returns true if the path matches this pathspec.


[View source]