Exgit.RefStore.Memory (exgit v0.1.0)

Copy Markdown View Source

In-memory implementation of the Exgit.RefStore protocol.

Used by Exgit.clone/2 when no :path option is given (the default), and by clone(url, lazy: true) regardless of whether a path is set (lazy+disk isn't yet supported).

All operations are pure over a struct value; there is no shared ETS table or process. Two holders of the same struct see the same refs.

Summary

Types

ref_value()

@type ref_value() :: binary() | {:symbolic, String.t()}

t()

@type t() :: %Exgit.RefStore.Memory{refs: %{required(String.t()) => ref_value()}}

Functions

delete_ref(store, ref)

@spec delete_ref(t(), String.t()) :: {:ok, t()} | {:error, :not_found}

list_refs(memory, prefix \\ "")

@spec list_refs(t(), String.t()) :: [{String.t(), ref_value()}]

new()

@spec new() :: t()

read_ref(memory, ref)

@spec read_ref(t(), String.t()) :: {:ok, ref_value()} | {:error, :not_found}

resolve_ref(store, ref)

@spec resolve_ref(t(), String.t()) ::
  {:ok, binary()} | {:error, :not_found | :too_deep | :cycle}

write_ref(store, ref, value, opts \\ [])

@spec write_ref(t(), String.t(), ref_value(), keyword()) ::
  {:ok, t()} | {:error, term()}