diff options
-rw-r--r-- | lib/bb/fetch2/git.py | 8 | ||||
-rw-r--r-- | lib/bb/tests/fetch.py | 34 |
2 files changed, 42 insertions, 0 deletions
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py index 59827e304fa..3d6a78a7507 100644 --- a/lib/bb/fetch2/git.py +++ b/lib/bb/fetch2/git.py @@ -72,6 +72,7 @@ import re import bb import errno from bb import data +from bb.fetch2 import encodeurl from bb.fetch2 import FetchMethod from bb.fetch2 import runfetchcmd from bb.fetch2 import logger @@ -95,6 +96,13 @@ class Git(FetchMethod): init git specific variable within url data so that the git method like latest_revision() can work """ + # Sanitize the path, to ensure it does not end in a '/'. + # Git does this internally, so really all this does is affect any + # bitbake mirror paths, as '/' is translated to a '.'. + if ud.path.endswith('/'): + ud.path = ud.path[:-1] + ud.url = encodeurl((ud.type, ud.host, ud.path, ud.user, ud.pswd, ud.parm)) + if 'protocol' in ud.parm: ud.proto = ud.parm['protocol'] elif not ud.host: diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py index 5ff156ccddc..e5db74bdbba 100644 --- a/lib/bb/tests/fetch.py +++ b/lib/bb/tests/fetch.py @@ -230,6 +230,36 @@ class URITest(unittest.TestCase): 'query': {}, 'relative': False }, + "git://example.net/path/example": { + 'uri': 'git://example.net/path/example', + 'scheme': 'git', + 'hostname': 'example.net', + 'port': None, + 'hostport': 'example.net', + 'path': '/path/example', + 'userinfo': '', + 'userinfo': '', + 'username': '', + 'password': '', + 'params': {}, + 'query': {}, + 'relative': False + }, + "git://example.net/path/example/": { + 'uri': 'git://example.net/path/example', + 'scheme': 'git', + 'hostname': 'example.net', + 'port': None, + 'hostport': 'example.net', + 'path': '/path/example', + 'userinfo': '', + 'userinfo': '', + 'username': '', + 'password': '', + 'params': {}, + 'query': {}, + 'relative': False + }, "http://somesite.net;someparam=1": { 'uri': 'http://somesite.net;someparam=1', 'scheme': 'http', @@ -393,6 +423,10 @@ class MirrorUriTest(FetcherTest): : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http") : "git://somewhere.org/somedir/git.invalid.infradead.org.foo.mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", + ("git://example.net/path/example;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://path/MIRRORNAME") + : "git://path/example.net.path.example;tag=1234567890123456789012345678901234567890", + ("git://example.net/path/example/;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://path/MIRRORNAME") + : "git://path/example.net.path.example;tag=1234567890123456789012345678901234567890", #Renaming files doesn't work #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz" |