Implements the Git.Command behaviour for git stash.
Supports listing stash entries (default), saving (pushing) changes to the stash, popping the top stash entry, and dropping a stash entry.
Summary
Types
Functions
Returns the argument list for git stash.
- If
:saveis true, buildsgit stash push [-m <message>] [-u]. - If
:popis true, buildsgit stash pop [stash@{index}]. - If
:dropis true, buildsgit stash drop [stash@{index}]. - Otherwise, lists stash entries with
git stash list.
Examples
iex> Git.Commands.Stash.args(%Git.Commands.Stash{})
["stash", "list"]
iex> Git.Commands.Stash.args(%Git.Commands.Stash{save: true})
["stash", "push"]
iex> Git.Commands.Stash.args(%Git.Commands.Stash{save: true, message: "wip"})
["stash", "push", "-m", "wip"]
iex> Git.Commands.Stash.args(%Git.Commands.Stash{pop: true})
["stash", "pop"]
iex> Git.Commands.Stash.args(%Git.Commands.Stash{drop: true, index: 1})
["stash", "drop", "stash@{1}"]
@spec parse_output(String.t(), non_neg_integer()) :: {:ok, [Git.StashEntry.t()]} | {:ok, :done} | {:error, {String.t(), non_neg_integer()}}
Parses the output of git stash.
For list operations (exit 0), parses each line into a Git.StashEntry struct.
For save/pop/drop operations (exit 0), returns {:ok, :done}.
On failure, returns {:error, {stdout, exit_code}}.