summaryrefslogtreecommitdiff
path: root/lib/gall/object.lua
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 15:46:54 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 15:46:54 +0100
commitea949ae3bb60172aa6cf84680dff308df13686e7 (patch)
treeae239d68ee110ca4ad1b979f506b032a4da61c69 /lib/gall/object.lua
parent7b6f77c46b65b44ed8d69f4b6a4859893a7542c6 (diff)
downloadgall-ea949ae3bb60172aa6cf84680dff308df13686e7.tar.gz
GALL.OBJECT: Add tests to cover gall.object
Diffstat (limited to 'lib/gall/object.lua')
-rw-r--r--lib/gall/object.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/gall/object.lua b/lib/gall/object.lua
index 3b904c5..2772587 100644
--- a/lib/gall/object.lua
+++ b/lib/gall/object.lua
@@ -13,6 +13,10 @@ local tag = require "gall.tag"
local repos = setmetatable({}, {__mode="k"})
+local known_types = {
+ blob = true, commit = true, tree = true, tag = true,
+}
+
local function _objectindex(obj, field)
local ok, ret
if field == "type" then
@@ -22,6 +26,7 @@ local function _objectindex(obj, field)
elseif field == "raw" then
ok, ret = repos[obj]:rawgather("cat-file", (obj.type == "tag" and "tag" or "-p"), obj.sha)
elseif field == "content" then
+ assert(known_types[obj.type], "Unknown type: " .. obj.type)
if obj.type == "blob" then
ok, ret = 0, obj.raw
elseif obj.type == "commit" then
@@ -30,8 +35,6 @@ local function _objectindex(obj, field)
ok, ret = 0, tree.new(repos[obj], obj)
elseif obj.type == "tag" then
ok, ret = 0, tag.new(repos[obj], obj)
- else
- error("Unknown type <" .. obj.type .. "> for content parse")
end
else
error("Unknown field <" .. tostring(field) .. ">")