From 138374296e251b8f2aef62cdd89dd406ebefd7bc Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Wed, 20 Nov 2013 17:46:03 +0100 Subject: [PATCH] Document generic_git.sourceset2ref(), improve error reporting Signed-off-by: Tobias Ulmer --- generic/generic_git.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/generic/generic_git.lua b/generic/generic_git.lua index cb7d59d..66e8c2a 100644 --- a/generic/generic_git.lua +++ b/generic/generic_git.lua @@ -757,16 +757,21 @@ function generic_git.verify_head_match_tag(gitwc, verify_tag) 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" or - (sourceset == "lazytag" and tag == "^") then + if sourceset == "branch" or (sourceset == "lazytag" and tag == "^") then return string.format("refs/heads/%s", branch) - elseif sourceset == "tag" or - (sourceset == "lazytag" and tag ~= "^") then + elseif sourceset == "tag" or (sourceset == "lazytag" and tag ~= "^") then return string.format("refs/tags/%s", tag) end - return nil, "invalid sourceset" + + return false, err.new("not a valid sourceset combination: %q %q %q", + sourceset, branch, tag) end --- Create a new git source repository. -- 2.39.5