# `Git.Commands.Rebase`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/commands/rebase.ex#L1)

Implements the `Git.Command` behaviour for `git rebase`.

Supports rebasing a branch onto an upstream ref, as well as aborting,
continuing, and skipping in-progress rebases.

## Unsupported options

The `--interactive` (`-i`) flag is intentionally not supported because it
requires an interactive editor session, which cannot be driven by a
non-interactive CLI wrapper.

# `t`

```elixir
@type t() :: %Git.Commands.Rebase{
  abort: boolean(),
  autosquash: boolean(),
  autostash: boolean(),
  branch: String.t() | nil,
  continue_rebase: boolean(),
  force_rebase: boolean(),
  keep_empty: boolean(),
  no_autosquash: boolean(),
  no_autostash: boolean(),
  no_keep_empty: boolean(),
  no_stat: boolean(),
  onto: String.t() | nil,
  quiet: boolean(),
  rebase_merges: boolean(),
  skip: boolean(),
  stat: boolean(),
  upstream: String.t() | nil,
  verbose: boolean()
}
```

# `args`

```elixir
@spec args(t()) :: [String.t()]
```

Returns the argument list for `git rebase`.

When `:abort`, `:continue_rebase`, or `:skip` is `true`, builds the
corresponding mutation command. Otherwise builds the full rebase command
with all applicable flags.

## Examples

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{abort: true})
    ["rebase", "--abort"]

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{continue_rebase: true})
    ["rebase", "--continue"]

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{skip: true})
    ["rebase", "--skip"]

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{upstream: "main"})
    ["rebase", "main"]

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{upstream: "main", branch: "feat"})
    ["rebase", "main", "feat"]

    iex> Git.Commands.Rebase.args(%Git.Commands.Rebase{onto: "main", upstream: "feature"})
    ["rebase", "--onto", "main", "feature"]

# `parse_output`

```elixir
@spec parse_output(String.t(), non_neg_integer()) ::
  {:ok, Git.RebaseResult.t()}
  | {:ok, :done}
  | {:error, {String.t(), non_neg_integer()}}
```

Parses the output of `git rebase`.

For mutation operations (abort, continue, skip) with exit code 0, returns
`{:ok, :done}`. For normal rebase operations, parses into a
`Git.RebaseResult` struct. On failure, returns
`{:error, {stdout, exit_code}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
