Create a record for tree entries

This commit is contained in:
Carlos Martín Nieto
2013-06-06 14:08:53 +02:00
parent 267353ea21
commit a0ded06b7a
4 changed files with 18 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ defmodule Geef do
alias Geef.Object
alias Geef.Commit
alias Geef.Tree
alias Geef.TreeEntry
alias Geef.Blob
alias Geef.Tag
end

View File

@@ -1,5 +1,8 @@
defrecord Geef.TreeEntry, Record.extract(:geef_tree_entry, from: "src/geef_records.hrl")
defmodule Geef.Tree do
alias Geef.Object
alias Geef.TreeEntry
def lookup(repo, id) do
case :geef_tree.lookup(repo, id) do
@@ -11,7 +14,12 @@ defmodule Geef.Tree do
end
def get(tree = Object[type: :tree], path) do
:geef_tree.get(set_elem(tree, 0, :geef_object), path)
case :geef_tree.get(set_elem(tree, 0, :geef_object), path) do
{:ok, entry} ->
{:ok, TreeEntry.new entry}
error ->
error
end
end
end