Implements the Git.Command behaviour for git sparse-checkout.
Supports initializing, setting, adding, listing, disabling, reapplying, and checking rules for sparse-checkout.
Summary
Functions
Returns the argument list for git sparse-checkout.
Parses the output of git sparse-checkout.
Types
Functions
Returns the argument list for git sparse-checkout.
- If
:initis true, buildsgit sparse-checkout init [--cone] [--sparse-index]. - If
:setis non-empty, buildsgit sparse-checkout set [--cone] [--no-cone] <patterns...>. - If
:addis non-empty, buildsgit sparse-checkout add [--cone] [--no-cone] <patterns...>. - If
:disableis true, buildsgit sparse-checkout disable. - If
:reapplyis true, buildsgit sparse-checkout reapply. - If
:check_rulesis true, buildsgit sparse-checkout check-rules. - Otherwise, lists current patterns with
git sparse-checkout list.
Examples
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{})
["sparse-checkout", "list"]
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{init: true, cone: true})
["sparse-checkout", "init", "--cone"]
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{set: ["src/", "docs/"], cone: true})
["sparse-checkout", "set", "--cone", "src/", "docs/"]
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{add: ["tests/"]})
["sparse-checkout", "add", "tests/"]
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{disable: true})
["sparse-checkout", "disable"]
iex> Git.Commands.SparseCheckout.args(%Git.Commands.SparseCheckout{reapply: true})
["sparse-checkout", "reapply"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [String.t()]} | {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git sparse-checkout.
For list operations (exit 0), returns {:ok, [pattern]} with one pattern
per line. For all mutation operations (exit 0), returns {:ok, :done}.
On failure, returns {:error, {stdout, exit_code}}.