summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorPeter Hoyes <Peter.Hoyes@arm.com>2023-06-16 13:36:49 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-27 15:28:56 +0100
commit8b0fc4850dc31bb7e7be0001414468b1d3f80846 (patch)
treeac11c4c538f578e219297344c9dfea52f87d568b /bitbake/lib/bb/tests/fetch.py
parentbaf345598d147fa798e4b1dd20992f8bed0a5c0e (diff)
downloadpoky-8b0fc4850dc31bb7e7be0001414468b1d3f80846.tar.gz
bitbake: bitbake: tests/fetch: Set git config if not already set
git config returns an error code if user.email or user.name are not set, so bb.process.run raises an ExecutionError, failing the test. Improve the logic by catching the ExectionError and using this to set a default value. Change a direct invocation of 'git init' to use self.git_init so that it follows the code path above. Remove the related comment from the README now that git sets up the user details automatically. (Bitbake rev: 0c7079d0609a13713b890a9675abd9fba032f199) Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r--bitbake/lib/bb/tests/fetch.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 871c174e82..8ca7e6c155 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -429,9 +429,15 @@ class FetcherTest(unittest.TestCase):
429 # a common setup is to use other default 429 # a common setup is to use other default
430 # branch than master. 430 # branch than master.
431 self.git(['checkout', '-b', 'master'], cwd=cwd) 431 self.git(['checkout', '-b', 'master'], cwd=cwd)
432 if not self.git(['config', 'user.email'], cwd=cwd): 432
433 try:
434 self.git(['config', 'user.email'], cwd=cwd)
435 except bb.process.ExecutionError:
433 self.git(['config', 'user.email', 'you@example.com'], cwd=cwd) 436 self.git(['config', 'user.email', 'you@example.com'], cwd=cwd)
434 if not self.git(['config', 'user.name'], cwd=cwd): 437
438 try:
439 self.git(['config', 'user.name'], cwd=cwd)
440 except bb.process.ExecutionError:
435 self.git(['config', 'user.name', 'Your Name'], cwd=cwd) 441 self.git(['config', 'user.name', 'Your Name'], cwd=cwd)
436 442
437class MirrorUriTest(FetcherTest): 443class MirrorUriTest(FetcherTest):
@@ -3038,7 +3044,7 @@ class FetchPremirroronlyLocalTest(FetcherTest):
3038 self.mirrorname = "git2_git.fake.repo.bitbake.tar.gz" 3044 self.mirrorname = "git2_git.fake.repo.bitbake.tar.gz"
3039 recipeurl = "git:/git.fake.repo/bitbake" 3045 recipeurl = "git:/git.fake.repo/bitbake"
3040 os.makedirs(self.gitdir) 3046 os.makedirs(self.gitdir)
3041 self.git("init", self.gitdir) 3047 self.git_init(cwd=self.gitdir)
3042 for i in range(0): 3048 for i in range(0):
3043 self.git_new_commit() 3049 self.git_new_commit()
3044 bb.process.run('tar -czvf {} .'.format(os.path.join(self.mirrordir, self.mirrorname)), cwd = self.gitdir) 3050 bb.process.run('tar -czvf {} .'.format(os.path.join(self.mirrordir, self.mirrorname)), cwd = self.gitdir)