Commit: grab the tree
This commit is contained in:
@@ -2,6 +2,8 @@ defmodule Geef.Commit do
|
||||
alias Geef.Object
|
||||
import Object, only: :macros
|
||||
|
||||
@type t :: Object[type: :commit]
|
||||
|
||||
def lookup(repo, id) do
|
||||
case :geef_commit.lookup(repo, id) do
|
||||
{:ok, commit} ->
|
||||
@@ -11,8 +13,22 @@ defmodule Geef.Commit do
|
||||
end
|
||||
end
|
||||
|
||||
@spec tree_id(Object.t) :: Oid.t
|
||||
def tree_id(commit = Object[type: :commit]) do
|
||||
:geef_commit.tree_id(rebind(commit))
|
||||
end
|
||||
|
||||
@spec tree(t) :: {:ok, Tree.t} | {:error, any}
|
||||
def tree(commit = Object[type: :commit]) do
|
||||
case :geef_commit.tree(rebind(commit)) do
|
||||
{:ok, tree} ->
|
||||
{:ok, Object.from_erl(tree)}
|
||||
error = {:error, _} ->
|
||||
error
|
||||
end
|
||||
end
|
||||
|
||||
@spec tree!(t) :: Tree.t
|
||||
def tree!(commit = Object[type: :commit]), do: tree(commit) |> Geef.assert_ok
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user