return true
end
+--- Helper to generate refs/tags string.
+-- @param tag Tag
+-- @return refs/tags/tag
+function generic_git.refs_tags(tag)
+ assertIsStringN(tag)
+ return "refs/tags/"..tag
+end
+
+local refs_tags = generic_git.refs_tags
+
+--- Helper to generate refs/heads string
+-- @param branch Branch
+-- @return refs/heads/branch
+function generic_git.refs_heads(branch)
+ assertIsStringN(branch)
+ return "refs/heads/"..branch
+end
+
+local refs_heads = generic_git.refs_heads
+
--- Create argument vector for calling git.
-- Defaults: If git_dir is given and the default for work_tree is requested,
-- it's assumed to be one directory level up. If work_tree is given and the
local e = err.new("verifying remote tag")
local rc, re, rtag, argv, rid, lid
- rc, re, rid = generic_git.lookup_id(gitdir, true, "refs/tags/" .. tag)
+ rc, re, rid = generic_git.lookup_id(gitdir, true, refs_tags(tag))
if not rc then
return false, e:cat(re)
end
return false, e:cat(re)
end
- rc, re, lid = generic_git.lookup_id(gitdir, false, "refs/tags/" .. tag)
+ rc, re, lid = generic_git.lookup_id(gitdir, false, refs_tags(tag))
if not rc then
return false, e:cat(re)
end
end
argv = { "--git-dir="..gitdir, "config", "branch.master.merge",
- "refs/heads/master" }
+ refs_heads("master") }
rc, re = generic_git.git(argv)
if not rc then
return false, e:cat(re)
local tools = require("tools")
local url = require("url")
+local refs_tags = generic_git.refs_tags
+local refs_heads = generic_git.refs_heads
+
git.git_source = class("git_source", source.basic_source)
function git.git_source.static:is_scm_source_class()
gitdir = e2lib.join(e2tool.root(), self:get_working(), ".git")
if sourceset == "branch" then
- ref = string.format("refs/heads/%s", self:get_branch())
+ ref = refs_heads(self:get_branch())
rc, re, id = generic_git.lookup_id(gitdir, false, ref)
if not rc then
return false, e:cat(re)
end
elseif sourceset == "tag" then
- ref = string.format("refs/tags/%s", self:get_tag())
+ ref = refs_tags(self:get_tag())
rc, re, id = generic_git.lookup_id(gitdir, false, ref)
if not rc then
-- check if branch exists
local gitdir = e2lib.join(e2tool.root(), self:get_working(), ".git")
- local ref = string.format("refs/heads/%s", self._branch)
+ local ref = refs_heads(self._branch)
local id
rc = self:working_copy_available()
end
rc, re, id = generic_git.lookup_id(git_dir, false,
- "refs/heads/" .. self:get_branch())
+ refs_heads(self:get_branch()))
if not rc then
return false, e:cat(re)
elseif not id then
end
rc, re = generic_git.git_checkout1(work_tree,
- "refs/heads/" .. self:get_branch())
+ refs_heads(self:get_branch()))
if not rc then
return false, e:cat(re)
end
return true
end
- if branch ~= "refs/heads/" .. self:get_branch() then
+ if branch ~= refs_heads(self:get_branch()) then
e2lib.warnf("WOTHER", "not on configured branch. Skipping.")
return true
end
table.insert(git_argv, "--format=tar")
if sourceset == "branch" then
- table.insert(git_argv, "refs/heads/" .. self:get_branch())
+ table.insert(git_argv, refs_heads(self:get_branch()))
elseif sourceset == "tag" then
- table.insert(git_argv, "refs/tags/" .. self:get_tag())
+ table.insert(git_argv, refs_tags(self:get_tag()))
else
error(err.new("invalid sourceset: %s", sourceset))
end
local ref, tmpfn
if sourceset == "tag" then
- ref = string.format("refs/tags/%s", src:get_tag())
+ ref = refs_tags(src:get_tag())
else
- ref = string.format("refs/heads/%s", src:get_branch())
+ ref = refs_heads(src:get_branch())
end
tmpfn, re = e2lib.mktempfile()