summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Lee <gavlee888@live.ie>2015-10-28 17:14:11 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-10-30 18:59:04 +0100
commit92153e6b558845f696c669dd1cafe49b789e2b9f (patch)
tree78e45c87912d3733eaed258dec8891ee720b52a5
parent9b08ff46d495b694179d8c8dbe72b660a69d2040 (diff)
downloadgitano-92153e6b558845f696c669dd1cafe49b789e2b9f.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))