From: Tobias Ulmer Date: Tue, 26 Feb 2013 14:23:40 +0000 (+0100) Subject: Remove trailing slash from git urls, assembla.com can't handle it X-Git-Tag: e2factory-2.3.13rc1~1 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=f5c748ab776bab1294dbcda4cf50b80fdca596af;p=e2factory.git Remove trailing slash from git urls, assembla.com can't handle it While there, make generic_git.git_clone_url1() local and clean up a bit. Signed-off-by: Tobias Ulmer --- diff --git a/generic/generic_git.lua b/generic/generic_git.lua index b916d66..6dc3143 100644 --- a/generic/generic_git.lua +++ b/generic/generic_git.lua @@ -39,38 +39,43 @@ local tools = require("tools") local err = require("err") local strict = require("strict") ---- clone a git repository --- @param surl url to the server --- @param location location relative to the server url --- @param destdir --- @param skip_checkout bool: pass -n to git clone? --- @return true on success, false on error --- @return nil, an error object on failure -function generic_git.git_clone_url1(surl, location, destdir, skip_checkout) - if (not surl) or (not location) or (not destdir) then - e2lib.abort("git_clone_url1(): missing parameter") - end +--- Clone a git repository. +-- @param surl URL to the git repository (string). +-- @param destdir Destination on file system (string). Must not exist. +-- @param skip_checkout Pass -n to git clone? (boolean) +-- @return True on success, false on error +-- @return Error object on failure +local function git_clone_url(surl, destdir, skip_checkout) local rc, re local e = err.new("cloning git repository") - local full_url = string.format("%s/%s", surl, location) - local u, re = url.parse(full_url) + + if (not surl) or (not destdir) then + return false, err.new("git_clone_url(): missing parameter") + end + + local u, re = url.parse(surl) if not u then return false, e:cat(re) end + local src, re = generic_git.git_url1(u) if not src then return false, e:cat(re) end + local flags = "" if skip_checkout then flags = "-n" end - local cmd = string.format("git clone %s --quiet %s %s", flags, - e2lib.shquote(src), e2lib.shquote(destdir)) + + local cmd = string.format("git clone %s --quiet %s %s", flags, + e2lib.shquote(src), e2lib.shquote(destdir)) + local rc, re = e2lib.callcmd_log(cmd) if rc ~= 0 then return false, e:cat(re) end + return true, nil end @@ -308,7 +313,7 @@ function generic_git.git_clone_from_server(c, server, location, destdir, if not surl then return false, e:cat(re) end - local rc, re = generic_git.git_clone_url1(surl, "", destdir, skip_checkout) + local rc, re = git_clone_url(surl, destdir, skip_checkout) if not rc then return false, re end