Gitignore (Gitignore v0.1.0)

Copy Markdown View Source

Parse and match gitignore-style rules.

Summary

Functions

Returns the matching rule, similar to git check-ignore -v.

Compiles rules into a matcher.

Returns true when the path is ignored.

Loads .gitignore files from root into a stack.

Parses ignore-file content into rules.

Functions

check(matcher, path, opts)

@spec check(Gitignore.Matcher.t(), binary(), keyword()) ::
  {:ignored | :unignored, Gitignore.Rule.t()} | :not_ignored

Returns the matching rule, similar to git check-ignore -v.

compile(rules, opts \\ [])

@spec compile(
  [Gitignore.Rule.t()],
  keyword()
) :: Gitignore.Matcher.t()

Compiles rules into a matcher.

ignored?(matcher, path, opts)

@spec ignored?(Gitignore.Matcher.t(), binary(), keyword()) :: boolean()

Returns true when the path is ignored.

load(root, opts \\ [])

@spec load(
  Path.t(),
  keyword()
) :: {:ok, Gitignore.Stack.t()} | {:error, term()}

Loads .gitignore files from root into a stack.

parse(content)

@spec parse(binary()) :: [Gitignore.Rule.t()]

Parses ignore-file content into rules.