Files
geef/src/geef_commit.erl
Carlos Martín Nieto 4a2f2e8ab2 Namespace the records
This makes it useful for users of the bindings. The naming is the same
as the module to allow elixir to treat the records in much the same
way as its native module/record hybrid.
2013-05-13 11:05:59 +02:00

25 lines
647 B
Erlang

-module(geef_commit).
-export([tree_id/1, tree/1, id/1, lookup/2]).
-include("geef_records.hrl").
-spec tree_id(geef_object()) -> geef_oid().
tree_id(#geef_object{type=commit,handle=Handle}) ->
Oid = geef_nif:commit_tree_id(Handle),
#geef_oid{oid=Oid}.
tree(#geef_object{type=commit,handle=Handle}) ->
case geef_nif:commit_tree(Handle) of
{ok, Type, Handle} ->
{ok, #geef_object{type=Type, handle=Handle}};
Other ->
Other
end.
-spec lookup(pid(), geef_oid() | iolist()) -> geef_object().
lookup(Repo, Id) ->
geef_object:lookup(Repo, Id, commit).
id(Obj = #geef_object{type=commit}) ->
geef_object:id(Obj).