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

Implements the `Git.Command` behaviour for `git name-rev`.

Finds a symbolic name for a given commit. With `:name_only` the output is
just the name; otherwise git prints the input followed by the name. With
`:tags` only tags are used to name the commit.

# `t`

```elixir
@type t() :: %Git.Commands.NameRev{
  commit: String.t() | nil,
  name_only: boolean(),
  tags: boolean()
}
```

# `args`

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

Returns the argument list for `git name-rev`.

## Examples

    iex> Git.Commands.NameRev.args(%Git.Commands.NameRev{commit: "HEAD"})
    ["name-rev", "HEAD"]

    iex> Git.Commands.NameRev.args(%Git.Commands.NameRev{commit: "HEAD", name_only: true})
    ["name-rev", "--name-only", "HEAD"]

    iex> Git.Commands.NameRev.args(%Git.Commands.NameRev{commit: "HEAD", name_only: true, tags: true})
    ["name-rev", "--name-only", "--tags", "HEAD"]

# `parse_output`

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

Parses the output of `git name-rev`.

On success, returns `{:ok, name}` with the trimmed output string. On a
non-zero exit code, returns `{:error, {stdout, exit_code}}`.

---

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