summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Lee <gavlee888@live.ie>2014-06-30 12:09:46 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-07-07 15:28:45 +0100
commitaedb1a2751840753824c95d7326f2e53bceda085 (patch)
treed51316ce653d98db617897ebd806906641338866
parentef7cb90b7e3df1f953d9190f1193101ac4c2f9db (diff)
downloadgitano-archive-plugin.tar.gz
git-archive command as pluginarchive-plugin
-rw-r--r--plugins/archive-plugin.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/plugins/archive-plugin.lua b/plugins/archive-plugin.lua
new file mode 100644
index 0000000..4e29074
--- /dev/null
+++ b/plugins/archive-plugin.lua
@@ -0,0 +1,33 @@
+local gitano = require "gitano"
+local sp = require "luxio.subprocess"
+
+local function builtin_upload_archive_validate(config, repo, cmdline)
+ -- git-upload-archive repo
+ if #cmdline > 2 then
+ return false
+ end
+ cmdline[2] = repo:fs_path()
+ return true
+end
+
+local function builtin_upload_archive_prep(config, repo, cmdline, context)
+ if repo.is_nascent then
+ return "deny", "Repository " .. repo.name .. " does not exist"
+ end
+ -- git-upload-archive is always a simple write operation
+ context.operation = "read"
+ return repo:run_lace(context)
+end
+
+local function builtin_upload_archive_run(config, repo, cmdline, env)
+ local cmdcopy = {env=env}
+ for i = 1, #cmdline do cmdcopy[i] = cmdline[i] end
+ local proc = sp.spawn(cmdcopy)
+ return proc:wait()
+end
+
+assert(gitano.command.register("git-upload-archive", nil, nil,
+ builtin_upload_archive_validate,
+ builtin_upload_archive_prep,
+ builtin_upload_archive_run,
+ true, true))