Implements the Git.Command behaviour for git reset.
Supports two forms:
- whole-tree reset,
git reset --<mode> <ref>, with:modeone of:soft,:mixed(default),:hard,:merge, or:keep - pathspec reset,
git reset <ref> -- <paths>, selected by giving:files. This unstages the listed paths;:modedoes not apply to this form (git rejects a mode flag together with a pathspec).
Summary
Types
Functions
Returns the argument list for git reset.
With :files, builds the pathspec form git reset [-q] <ref> -- <paths>.
Otherwise builds the whole-tree form git reset --<mode> [-q] <ref>. The mode
defaults to :mixed and the ref defaults to "HEAD".
Examples
iex> Git.Commands.Reset.args(%Git.Commands.Reset{})
["reset", "--mixed", "HEAD"]
iex> Git.Commands.Reset.args(%Git.Commands.Reset{mode: :soft, ref: "HEAD~1"})
["reset", "--soft", "HEAD~1"]
iex> Git.Commands.Reset.args(%Git.Commands.Reset{mode: :hard})
["reset", "--hard", "HEAD"]
iex> Git.Commands.Reset.args(%Git.Commands.Reset{files: ["a.ex", "b.ex"]})
["reset", "HEAD", "--", "a.ex", "b.ex"]
iex> Git.Commands.Reset.args(%Git.Commands.Reset{mode: :keep, quiet: true})
["reset", "--keep", "-q", "HEAD"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git reset.
On success (exit code 0), returns {:ok, :done}. On failure, returns
{:error, {stdout, exit_code}}.