return true
end
---- Translate sourceset, branch and tag into a git ref.
--- @param sourceset Source setting.
--- @param branch Source branch.
--- @param tag Source tag.
--- @return git refs string, or false on error.
--- @return Error object on failure.
-function generic_git.sourceset2ref(sourceset, branch, tag)
- if sourceset == "branch" then
- return string.format("refs/heads/%s", branch)
- elseif sourceset == "tag" then
- return string.format("refs/tags/%s", tag)
- end
-
- return false, err.new("not a valid sourceset combination: %q %q %q",
- sourceset, branch, tag)
-end
-
--- Create a new git source repository.
-- @param c cache table
-- @param lserver string: local server
if sourceset == "tag" or sourceset == "branch" then
local ref, tmpfn
- ref, re = generic_git.sourceset2ref(sourceset, src:get_branch(), src:get_tag())
- if not ref then
- return false, e:cat(re)
+ if sourceset == "tag" then
+ ref = string.format("refs/tags/%s", src:get_tag())
+ else
+ ref = string.format("refs/heads/%s", src:get_branch())
end
tmpfn, re = e2lib.mktempfile()