From: Tobias Ulmer Date: Fri, 3 May 2019 17:20:16 +0000 (+0200) Subject: git: optionally skip workdir checkout X-Git-Tag: e2factory-2.3.18rc1~5 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=3e697abbe2b7c4d12bb935fab02faad086024a8e;p=e2factory.git git: optionally skip workdir checkout Skips workdir checkout on git clone, like in older versions of e2factory. This may help to speed up fetch-sources of very large repos and reduces disk space requirements in some scenarios (CI). It's currently not documented and may go away. For one, configuring it via the source config is a little awkward. Signed-off-by: Tobias Ulmer --- diff --git a/plugins/git.lua b/plugins/git.lua index 1454603..f817b29 100644 --- a/plugins/git.lua +++ b/plugins/git.lua @@ -72,6 +72,7 @@ function git.git_source:initialize(rawsrc) ["working-copy"] = "working-copy", } self._commitids = {} + self._checkout = true self._xxxcommitid = false -- XXX: Not yet rc, re = e2lib.vrfy_dict_exp_keys(rawsrc, "e2source", { @@ -84,6 +85,7 @@ function git.git_source:initialize(rawsrc) "tag", "type", "working", + "checkout", -- XXX: undocumented on purpose }) if not rc then error(re) @@ -124,6 +126,13 @@ function git.git_source:initialize(rawsrc) self._branch = rawsrc.branch or "" self._location = rawsrc.location self._tag = rawsrc.tag + + if rawsrc.checkout then + if type(rawsrc.checkout) ~= boolean then + error(err.new("checkout' must be a boolean")) + end + self._checkout = rawsrc.checkout + end end function git.git_source:get_server() @@ -337,6 +346,9 @@ function git.git_source:display() if self._xxxcommitid then table.insert(d, string.format("commitid = %s", self._xxxcommitid)) end + if self._checkout ~= true then + table.insert(d, string.format("checkout = %s", tostring(self._checkout))) + end table.insert(d, string.format("server = %s", self._server)) table.insert(d, string.format("location = %s", self._location)) table.insert(d, string.format("working = %s", self:get_working())) @@ -479,12 +491,17 @@ function git.git_source:fetch_source() e2lib.logf(2, "cloning %s:%s [%s]", self:get_server(), self:get_location(), self:get_branch()) + local skip_checkout = not self._checkout rc, re = generic_git.git_clone_from_server(cache.cache(), self:get_server(), - self:get_location(), work_tree, false --[[always checkout]]) + self:get_location(), work_tree, skip_checkout) if not rc then return false, e:cat(re) end + if not self._checkout then + return true + end + rc, re, id = generic_git.lookup_id(git_dir, generic_git.NO_REMOTE, refs_heads(self:get_branch())) if not rc then