From: Tobias Ulmer Date: Fri, 9 Nov 2018 16:22:44 +0000 (+0100) Subject: generic_git: add a few helpers for formatting refs X-Git-Tag: e2factory-2.3.18rc1~72 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=210099dd51857218bf8ed7c185e1f57a7e18c8be;p=e2factory.git generic_git: add a few helpers for formatting refs Signed-off-by: Tobias Ulmer --- diff --git a/generic/generic_git.lua b/generic/generic_git.lua index d8158d0..83c0580 100644 --- a/generic/generic_git.lua +++ b/generic/generic_git.lua @@ -99,6 +99,36 @@ end local refs_heads = generic_git.refs_heads +-- Helper to get the default remote string. +-- Trivial function to keep information in one place. +-- @param remote, defaults to "origin". +-- @return remote string. +function generic_git.refs_remote(remote) + return remote or "origin" +end + +--- Helper to generate refs/remotes// +-- @param branch Branch +-- @param remote Remote, defaults to refs_remote(). +-- @return refs/remotes/remote/branch +function generic_git.refs_remotes(branch, remote) + remote = generic_git.refs_remote(remote) + assertIsStringN(branch) + assertIsStringN(remote) + return "refs/remotes/"..remote.."/"..branch +end + +--- Helper to generate / +--@param branch Branch +--@param remote Remote, defaults to refs_remote(). +--@return remote/branch string +function generic_git.refs_remote_heads(branch, remote) + remote = generic_git.refs_remote(remote) + assertIsStringN(branch) + assertIsStringN(remote) + return remote.."/"..branch +end + --- 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