From d742c2956633007aec5894fa78a8a8060692592f Mon Sep 17 00:00:00 2001 From: Linus Ziegert Date: Tue, 8 Jan 2019 16:30:22 +0100 Subject: [PATCH] fetch2/gitsm.py: Enable SSH protocol option While fetching from a private git repo with submodules I encountered following error: ERROR: do_fetch: The URL: 'git@github.com//.git; protocol=git@github.com//.git;name=; bareclone=1;nocheckout=1;nobranch=1' is invalid and cannot be interpreted The reason is that gitsm.py cannot handle the syntax of git submodules which use SSH as protocol type. After a colon in the URI of a submodule is found the string before the colon is assigned as protocol type. So the different syntax of git URI's for SSH connections has to be considered. To fix this we split the URI at a colon. All protocol types that are supported by fetch2/git.py and use URI's use a colon except SSH. In the case there is a colon we can use the suffix as protocol type otherwise we assign SSH as protocol. Signed-off-by: Linus Ziegert --- lib/bb/fetch2/gitsm.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py index 35729dbc..4d9f603d 100644 --- a/lib/bb/fetch2/gitsm.py +++ b/lib/bb/fetch2/gitsm.py @@ -88,7 +88,17 @@ class GitSM(Git): module_hash = module_hash.split()[2] # Build new SRC_URI - proto = uris[module].split(':', 1)[0] + uri_parts = uris[module].split(':', 1) + if len(uri_parts) > 1: + proto = uri_parts[0] + else: + # If there is no colon in uri we get the protocol from the module + proto = ud.proto + + url = uris[module].replace('%s:' % proto, 'gitsm:', 1) + if "://" not in url: + url = "git://%s" % url + url = uris[module].replace('%s:' % proto, 'gitsm:', 1) url += ';protocol=%s' % proto url += ";name=%s" % module -- 2.17.1