summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPatrik Nordvall <patrik.nordvall95@gmail.com>2025-03-14 12:25:59 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-18 11:03:17 +0000
commit8180865c22000adc5114a062dbe67f4b02ea06d5 (patch)
tree14dfbdc98143a8107efc929b31521f2719cac46f /bitbake
parent85c2eb6d423be503fc3257340da890a36293d8e8 (diff)
downloadpoky-8180865c22000adc5114a062dbe67f4b02ea06d5.tar.gz
bitbake: fetch2/git: Restore escape quoting for the git url when used
This fixes a bug where escapes in the url path would not be properly restored for the git commands in the git fetcher. For example, a space which is encoded as '%20' was not properly encoded before the clone command. e.g. SRC_URI="git://git.openembedded.org/bitbake%20example/bitbake;protocol=https" resulted in git clone 'https://git.openembedded.org/bitbake example/bitbake' instead of git clone 'https://git.openembedded.org/bitbake%20example/bitbake' (Bitbake rev: be48024253b93215bb110cd1d05925e789ec9680) Signed-off-by: Patrik Nordvall <patrik.nordvall95@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/git.py3
-rw-r--r--bitbake/lib/bb/tests/fetch.py3
2 files changed, 5 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 9a15abaa79..a73fb79ac8 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -81,6 +81,7 @@ import shlex
81import shutil 81import shutil
82import subprocess 82import subprocess
83import tempfile 83import tempfile
84import urllib
84import bb 85import bb
85import bb.progress 86import bb.progress
86from contextlib import contextmanager 87from contextlib import contextmanager
@@ -888,7 +889,7 @@ class Git(FetchMethod):
888 username = ud.user + '@' 889 username = ud.user + '@'
889 else: 890 else:
890 username = "" 891 username = ""
891 return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path) 892 return "%s://%s%s%s" % (ud.proto, username, ud.host, urllib.parse.quote(ud.path))
892 893
893 def _revision_key(self, ud, d, name): 894 def _revision_key(self, ud, d, name):
894 """ 895 """
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index d000dc465d..0c87730c5e 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2508,11 +2508,13 @@ class GitURLWithSpacesTest(FetcherTest):
2508 test_git_urls = { 2508 test_git_urls = {
2509 "git://tfs-example.org:22/tfs/example%20path/example.git;branch=master" : { 2509 "git://tfs-example.org:22/tfs/example%20path/example.git;branch=master" : {
2510 'url': 'git://tfs-example.org:22/tfs/example%20path/example.git;branch=master', 2510 'url': 'git://tfs-example.org:22/tfs/example%20path/example.git;branch=master',
2511 'repo_url': 'git://tfs-example.org:22/tfs/example%20path/example.git',
2511 'gitsrcname': 'tfs-example.org.22.tfs.example_path.example.git', 2512 'gitsrcname': 'tfs-example.org.22.tfs.example_path.example.git',
2512 'path': '/tfs/example path/example.git' 2513 'path': '/tfs/example path/example.git'
2513 }, 2514 },
2514 "git://tfs-example.org:22/tfs/example%20path/example%20repo.git;branch=master" : { 2515 "git://tfs-example.org:22/tfs/example%20path/example%20repo.git;branch=master" : {
2515 'url': 'git://tfs-example.org:22/tfs/example%20path/example%20repo.git;branch=master', 2516 'url': 'git://tfs-example.org:22/tfs/example%20path/example%20repo.git;branch=master',
2517 'repo_url': 'git://tfs-example.org:22/tfs/example%20path/example%20repo.git',
2516 'gitsrcname': 'tfs-example.org.22.tfs.example_path.example_repo.git', 2518 'gitsrcname': 'tfs-example.org.22.tfs.example_path.example_repo.git',
2517 'path': '/tfs/example path/example repo.git' 2519 'path': '/tfs/example path/example repo.git'
2518 } 2520 }
@@ -2535,6 +2537,7 @@ class GitURLWithSpacesTest(FetcherTest):
2535 self.assertEqual(ud.lockfile, os.path.join(self.dldir, "git2", ref['gitsrcname'] + '.lock')) 2537 self.assertEqual(ud.lockfile, os.path.join(self.dldir, "git2", ref['gitsrcname'] + '.lock'))
2536 self.assertEqual(ud.clonedir, os.path.join(self.dldir, "git2", ref['gitsrcname'])) 2538 self.assertEqual(ud.clonedir, os.path.join(self.dldir, "git2", ref['gitsrcname']))
2537 self.assertEqual(ud.fullmirror, os.path.join(self.dldir, "git2_" + ref['gitsrcname'] + '.tar.gz')) 2539 self.assertEqual(ud.fullmirror, os.path.join(self.dldir, "git2_" + ref['gitsrcname'] + '.tar.gz'))
2540 self.assertEqual(ud.method._get_repo_url(ud), ref['repo_url'])
2538 2541
2539class CrateTest(FetcherTest): 2542class CrateTest(FetcherTest):
2540 @skipIfNoNetwork() 2543 @skipIfNoNetwork()