diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2016-01-13 15:25:22 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2016-01-13 15:25:22 +0000 |
commit | cc8cb13126944fd47ffecf5529045e8ebda9800e (patch) | |
tree | 68a714c29e3c5302052c99d832327d8d01c03b1b /lib | |
parent | b7c1869c1e778a002dca9ac60f11295b3d9cf681 (diff) | |
download | gitano-cc8cb13126944fd47ffecf5529045e8ebda9800e.tar.gz |
gitano.repository.git_command: Handle shallowUpdate config
If the repository is configured with git.receive.shallowUpdate
(as set by `gitanocmd config set git.receive.shallowUpdate true`)
then git will be run with receive.shallowUpdate set,
which allows shallow commits to be pushed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitano/repository.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitano/repository.lua b/lib/gitano/repository.lua index 982dc4d..e5f7927 100644 --- a/lib/gitano/repository.lua +++ b/lib/gitano/repository.lua @@ -722,9 +722,26 @@ function repo_method:save_admin(reason, author, committer) return self:run_checks() end +local _git_booleans = { + ["true"] = true, yes = true, on = true, + ["false"] = false, no = false, off = false, +} +local function _git_config_bool(v) + if type(v) == "string" then + return _git_booleans[v:lower()] + elseif type(v) == "boolean" then + return v + end + -- Intentional fall-through to return nil +end + function repo_method:git_command(t) local t_copy = util.deep_copy(t) table.insert(t_copy, 1, "git") + if _git_config_bool(self:conf_get "git.receive.shallowUpdate") then + table.insert(t_copy, 2, "-c") + table.insert(t_copy, 3, "receive.shallowUpdate=true") + end local proc = sp.spawn(t_copy) return proc:wait() end |