diff --git a/src/geef.erl b/src/geef.erl index 19618de..60f0261 100644 --- a/src/geef.erl +++ b/src/geef.erl @@ -1,3 +1,6 @@ +%%% @private +%%% NIF functions, not to be used directly. + -module(geef). -export([hex_to_raw/1, reference_list/1, reference_to_id/2, reference_glob/2, reference_lookup/2, reference_resolve/1, diff --git a/src/geef_oid.erl b/src/geef_oid.erl index b26118f..beadf39 100644 --- a/src/geef_oid.erl +++ b/src/geef_oid.erl @@ -1,3 +1,4 @@ +%%% @doc Dealing with object names -module(geef_oid). -ifdef(TEST). @@ -8,12 +9,13 @@ -export([parse/1, fmt/1]). +%% @doc Get the hex-encoded hash -spec fmt(oid()) -> binary(). fmt(#oid{oid=Oid}) -> geef:oid_fmt(Oid). - --spec parse(binary()) -> oid(). +%% @doc Parse an iolist as a hash +-spec parse(iolist()) -> oid(). parse(Sha) -> Oid = geef:oid_parse(Sha), #oid{oid=Oid}. diff --git a/src/geef_repo.erl b/src/geef_repo.erl index 8756607..2102ec9 100644 --- a/src/geef_repo.erl +++ b/src/geef_repo.erl @@ -4,14 +4,18 @@ -include("geef_records.hrl"). +%% @doc The repository's git-dir path -spec path(repo()) -> binary(). path(#repo{handle=Handle}) -> geef:repository_get_path(Handle). +%% @doc The repository's worktree path -spec workdir(repo()) -> binary(). workdir(#repo{handle=Handle}) -> geef:repository_get_workdir(Handle). +%% @doc The repository's current object database. This encompasses all +%% the configured backends. -spec odb(repo()) -> {ok, odb} | {error, term}. odb(#repo{handle=Handle}) -> case geef:repository_get_odb(Handle) of @@ -21,18 +25,23 @@ odb(#repo{handle=Handle}) -> Other end. +%% @doc Whether the repository is bare -spec is_bare(repo()) -> boolean(). is_bare(#repo{handle=Handle}) -> geef:repository_is_bare(Handle). +%% @doc List of references in the repository. -spec references(repo()) -> [binary()]. references(#repo{handle=Handle}) -> geef:reference_list(Handle). +%% @doc Discover a repository's path from a path contained inside it -spec discover(iolist()) -> {ok, binary()} | error | {error, term()}. discover(Path) -> geef:repository_discover(Path). +%% @doc Open an existing repository. Path must point to the git-dir or +%% worktree -spec open(iolist()) -> {ok, repo()} | {error, term()}. open(Path) -> case geef:repository_open(Path) of @@ -42,6 +51,7 @@ open(Path) -> Other end. +%% @doc Initialize a new repository -spec init(iolist(), boolean()) -> {ok, repo()} | {error, term()}. init(Path, Bare) -> case geef:repository_init(Path, Bare) of