Current section
Files
Jump to
Current section
Files
lib/git2/repository.ex
defmodule Git2.Repository do
@moduledoc """
I provide functions for working with repositories.
"""
@typedoc "I am a handle to a Git repository."
@type t() :: reference()
@doc """
I enumerate the branches of a repository.
"""
@spec enumerate_branches(t()) :: [
%{name: String.t(), id: String.t(), type: :local | :remote}
]
def enumerate_branches(repo) do
enumerate_branches(repo, nil)
end
@doc """
I enumerate the branches of a repository, and may filter this set to
either local or remote branches.
"""
@spec enumerate_branches(t(), :local | :remote | nil) :: [
%{name: String.t(), id: String.t(), type: :local | :remote}
]
defdelegate enumerate_branches(repo, filter),
to: Git2.NIF,
as: :repository_enumerate_branches
@doc """
I open a Git repository. On success, I return {:ok, handle}.
"""
@spec open(String.t()) :: {:ok, t()} | {:error, term()}
defdelegate open(path), to: Git2.NIF, as: :repository_open
@doc """
I parse a revision string to find a single commit object.
"""
@spec revparse_single_commit(t(), String.t()) ::
{:ok, String.t()} | {:error, term()}
defdelegate revparse_single_commit(repo, spec),
to: Git2.NIF,
as: :repository_revparse_single_commit
@doc """
I return the state of a repository.
"""
@spec state(t()) :: atom()
defdelegate state(repo), to: Git2.NIF, as: :repository_state
end