]> git.e2factory.org Git - e2factory.git/commitdiff
generic_git: add git_url_cache to turn server:location into git url
authorTobias Ulmer <tu@emlix.com>
Wed, 6 Mar 2019 18:03:10 +0000 (19:03 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 13 Mar 2019 16:29:43 +0000 (17:29 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/generic_git.lua

index a777823d7cd454475244335717f6bfca90410314..441479bb6b0fa21a16d53a169c25d0df166409f8 100644 (file)
@@ -560,6 +560,30 @@ function generic_git.git_url1(u)
     return giturl
 end
 
+-- Generate git URL string from cache/server/location.
+-- @param c table: a cache
+-- @param server string: server name
+-- @param location string: location
+-- @return string: the git url, or nil
+-- @return an error object on failure
+function generic_git.git_url_cache(c, server, location)
+    local rc, re, rurl, u, giturl
+
+    rurl, re = cache.remote_url(c, server, location) -- takes care of asserts
+    if not rurl then
+        return false, re
+    end
+    u, re = url.parse(rurl)
+    if not u then
+        return false, re
+    end
+    giturl, re = generic_git.git_url1(u)
+    if not giturl then
+        return false, re
+    end
+    return giturl
+end
+
 --- clone a git repository by server and location
 -- @param c Cache
 -- @param server