# `Git.Signing`
[🔗](https://github.com/joshrotenberg/git_wrapper_ex/blob/main/lib/git/signing.ex#L1)

Higher-level helpers for configuring commit and tag signing.

These thin wrappers set the relevant git config keys through
`Git.git_config/1` so callers do not have to remember the individual key
names. They configure how the repository signs; the actual signing happens
when a commit, tag, or merge is created with the corresponding `:sign`,
`:local_user`, or `:gpg_sign` option (or automatically once
`commit.gpgsign`/`tag.gpgsign` is enabled).

All functions accept an optional keyword list:

  * `:config` - a `Git.Config` struct forwarded to every git invocation
  * `:global`/`:local`/`:system` - the config scope to write. When no scope
    is given, the values are written to the local repository config.

## Examples

    # SSH signing with a generated key
    Git.Signing.use_ssh("/home/me/.ssh/id_ed25519.pub", config: cfg)

    # GPG signing with a key id
    Git.Signing.use_gpg("ABCD1234", config: cfg)

    # Also sign annotated tags by default
    Git.Signing.sign_tags(true, config: cfg)

# `sign_tags`

```elixir
@spec sign_tags(
  boolean(),
  keyword()
) :: {:ok, :done} | {:error, term()}
```

Sets `tag.gpgsign` so annotated tags are signed by default.

Returns `{:ok, :done}` on success or `{:error, term()}` on failure.

# `use_gpg`

```elixir
@spec use_gpg(
  String.t(),
  keyword()
) :: {:ok, :done} | {:error, term()}
```

Configures GPG-based signing.

Sets `user.signingkey` to `keyid` and `commit.gpgsign=true` so commits are
signed by default.

Returns `{:ok, :done}` when every key was written, or the first
`{:error, term()}` encountered.

# `use_ssh`

```elixir
@spec use_ssh(
  String.t(),
  keyword()
) :: {:ok, :done} | {:error, term()}
```

Configures SSH-based signing.

Sets `gpg.format=ssh`, `user.signingkey` to `key_path`, and
`commit.gpgsign=true` so commits are signed by default.

Returns `{:ok, :done}` when every key was written, or the first
`{:error, term()}` encountered.

---

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