Implements the Git.Command behaviour for git check-ignore.
Checks whether given paths are ignored by .gitignore rules. Supports
verbose output showing which pattern matched and non-matching mode.
Stdin mode (--stdin) is intentionally not supported because it requires
stdin piping which cannot be driven programmatically via System.cmd/3.
Summary
Types
Functions
Returns the argument list for git check-ignore.
Examples
iex> Git.Commands.CheckIgnore.args(%Git.Commands.CheckIgnore{paths: ["build/", "tmp.log"]})
["check-ignore", "build/", "tmp.log"]
iex> Git.Commands.CheckIgnore.args(%Git.Commands.CheckIgnore{paths: ["foo"], verbose: true})
["check-ignore", "-v", "foo"]
iex> Git.Commands.CheckIgnore.args(%Git.Commands.CheckIgnore{paths: ["foo"], verbose: true, non_matching: true})
["check-ignore", "-v", "-n", "foo"]
iex> Git.Commands.CheckIgnore.args(%Git.Commands.CheckIgnore{paths: ["foo"], no_index: true})
["check-ignore", "--no-index", "foo"]
iex> Git.Commands.CheckIgnore.args(%Git.Commands.CheckIgnore{paths: ["foo"], quiet: true})
["check-ignore", "-q", "foo"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [String.t()] | [map()]} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git check-ignore.
- Default mode: returns
{:ok, [String.t()]}with the list of ignored paths. - Verbose mode: returns
{:ok, [map]}where each map has:source,:line_number,:pattern, and:pathkeys. - Exit code 1 means no paths matched, which returns
{:ok, []}(not an error).