summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Lee <gavlee888@live.ie>2014-06-30 12:09:46 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2015-10-28 15:21:33 +0000
commit95d25edecbb29c782673e741241c20922763ce75 (patch)
tree786b19955726ec39e3a5fe99b599690be78bb081
parent8e29fb9c131a7e77eb15423d76acbc2df2c4c907 (diff)
downloadgitano-95d25edecbb29c782673e741241c20922763ce75.tar.bz2
git-archive command as 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..e117201
--- /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))