# `Minga.Extension.Git`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/extension/git.ex#L1)

Resolves git-sourced extensions by cloning and updating repos.

Extensions declared with `git:` are cloned to a local cache directory
(`~/.local/share/minga/extensions/{name}/`). On first load, the repo
is cloned. On subsequent boots, the cached checkout is used as-is.
Explicit updates via `SPC h e u` fetch and fast-forward.

# `update_info`

```elixir
@type update_info() :: %{
  name: atom(),
  old_ref: String.t(),
  new_ref: String.t(),
  commit_count: non_neg_integer(),
  branch: String.t() | nil
}
```

Summary of available updates for a git extension.

# `apply_update`

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

Applies a previously fetched update by fast-forwarding the local checkout.

# `current_ref`

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

Returns the current HEAD ref (short hash) for a cloned extension.

# `ensure_cloned`

```elixir
@spec ensure_cloned(atom(), %{
  url: String.t(),
  branch: String.t() | nil,
  ref: String.t() | nil
}) ::
  {:ok, String.t()} | {:error, String.t()}
```

Ensures the git repo is cloned locally. Returns the local path.

If the cache directory already exists, returns it immediately (no
network access). If missing, clones the repo. Respects `branch:` and
`ref:` options from the git config.

# `extension_path`

```elixir
@spec extension_path(atom()) :: String.t()
```

Returns the local cache path for a named extension.

# `fetch_updates`

```elixir
@spec fetch_updates(atom(), %{
  url: String.t(),
  branch: String.t() | nil,
  ref: String.t() | nil
}) ::
  {:ok, update_info()} | :up_to_date | {:error, String.t()}
```

Fetches remote changes and returns update info without applying them.

Returns `{:ok, update_info}` if there are new commits available,
`:up_to_date` if already current, or `{:error, reason}` on failure.

# `rollback`

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

Rolls back to a specific ref after a failed update or compile.

---

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