1.7 KiB · text 5af55d9
defmodule GitGud.Git.Backend do
@moduledoc """
Behaviour every git backend (Cli, Nif) implements.
See `GitGud.Git` for the public API and types.
"""
alias GitGud.Git
@callback available?() :: boolean()
@callback init_bare(Git.repo_path()) :: :ok | {:error, term()}
@callback list_refs(Git.repo_path()) :: {:ok, [Git.ref()]} | {:error, term()}
@callback log(Git.repo_path(), Git.sha(), keyword()) ::
{:ok, [Git.commit()]} | {:error, term()}
@callback commit(Git.repo_path(), Git.sha()) :: {:ok, Git.commit()} | {:error, term()}
@callback tree(Git.repo_path(), Git.sha()) :: {:ok, [Git.tree_entry()]} | {:error, term()}
@callback blob_bytes(Git.repo_path(), Git.sha()) :: {:ok, binary()} | {:error, term()}
@callback blob_meta(Git.repo_path(), Git.sha()) :: {:ok, Git.blob_meta()} | {:error, term()}
@callback diff_stats(Git.repo_path(), Git.sha() | nil, Git.sha()) ::
{:ok, Git.diff_stat()} | {:error, term()}
@callback diff(Git.repo_path(), Git.sha() | nil, Git.sha(), keyword()) ::
{:ok, String.t()} | {:error, term()}
@callback resolve(Git.repo_path(), String.t() | Git.sha()) ::
{:ok, Git.sha()} | {:error, term()}
@callback merge_base(Git.repo_path(), Git.sha(), Git.sha()) ::
{:ok, Git.sha()} | {:error, term()}
@callback merge_tree(Git.repo_path(), Git.sha(), Git.sha(), Git.sha()) ::
{:ok, Git.sha()} | {:error, term()}
@callback commit_tree(Git.repo_path(), Git.sha(), [Git.sha()], String.t(), keyword()) ::
{:ok, Git.sha()} | {:error, term()}
@callback update_ref(Git.repo_path(), String.t(), Git.sha(), Git.sha() | nil) ::
:ok | {:error, term()}
end