diff options
author | Mikko Rapeli <mikko.rapeli@bmw.de> | 2021-04-26 11:27:49 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-27 15:22:58 +0100 |
commit | b7cba05f8267182ac553f552a5f57a91fe5e7eee (patch) | |
tree | 47cdaed4427ce8d91130ff29091dadd1a16f2500 /bitbake | |
parent | a49e5c0f4f8947dcd6dea4a445f79bd9e426b6ed (diff) | |
download | poky-b7cba05f8267182ac553f552a5f57a91fe5e7eee.tar.gz |
bitbake: bitbake: tests/fetch: fix test execution without .gitconfig
A CI user validating changes does not have any git push rights or
even a .gitconfig file so fix tests so that they run
by setting the user.name and user.email for the repo before
committing changes.
Fixes errors like:
ERROR: test_that_unpack_throws_an_error_when_the_git_clone_nor_shallow_tarball_exist (bb.tests.fetch.GitShallowTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/builder/src/base/poky/bitbake/lib/bb/tests/fetch.py", line 2055, in test_that_unpack_throws_an_error_when_the_git_clone_nor_shallow_tarball_exist
self.add_empty_file('a')
File "/home/builder/src/base/poky/bitbake/lib/bb/tests/fetch.py", line 1562, in add_empty_file
self.git(['commit', '-m', msg, path], cwd)
File "/home/builder/src/base/poky/bitbake/lib/bb/tests/fetch.py", line 1553, in git
return bb.process.run(cmd, cwd=cwd)[0]
File "/home/builder/src/base/poky/bitbake/lib/bb/process.py", line 184, in run
raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
bb.process.ExecutionError: Execution of 'git commit -m a a' failed with exit code 128:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
(Bitbake rev: 1e1d1187e602aa1ef50c23551eec07f1a0cd81ef)
Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 57c0811f1ee19b6619f4840a39e01e3cb98c34c4)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index ddf6e97439..c156168151 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -679,6 +679,8 @@ class FetcherLocalTest(FetcherTest): | |||
679 | prefix='gitfetch_localusehead_') | 679 | prefix='gitfetch_localusehead_') |
680 | src_dir = os.path.abspath(src_dir) | 680 | src_dir = os.path.abspath(src_dir) |
681 | bb.process.run("git init", cwd=src_dir) | 681 | bb.process.run("git init", cwd=src_dir) |
682 | bb.process.run("git config user.email 'you@example.com'", cwd=src_dir) | ||
683 | bb.process.run("git config user.name 'Your Name'", cwd=src_dir) | ||
682 | bb.process.run("git commit --allow-empty -m'Dummy commit'", | 684 | bb.process.run("git commit --allow-empty -m'Dummy commit'", |
683 | cwd=src_dir) | 685 | cwd=src_dir) |
684 | # Use other branch than master | 686 | # Use other branch than master |
@@ -705,6 +707,8 @@ class FetcherLocalTest(FetcherTest): | |||
705 | prefix='gitfetch_localusehead_') | 707 | prefix='gitfetch_localusehead_') |
706 | src_dir = os.path.abspath(src_dir) | 708 | src_dir = os.path.abspath(src_dir) |
707 | bb.process.run("git init", cwd=src_dir) | 709 | bb.process.run("git init", cwd=src_dir) |
710 | bb.process.run("git config user.email 'you@example.com'", cwd=src_dir) | ||
711 | bb.process.run("git config user.name 'Your Name'", cwd=src_dir) | ||
708 | bb.process.run("git commit --allow-empty -m'Dummy commit'", | 712 | bb.process.run("git commit --allow-empty -m'Dummy commit'", |
709 | cwd=src_dir) | 713 | cwd=src_dir) |
710 | # Use other branch than master | 714 | # Use other branch than master |
@@ -1390,6 +1394,8 @@ class GitMakeShallowTest(FetcherTest): | |||
1390 | self.gitdir = os.path.join(self.tempdir, 'gitshallow') | 1394 | self.gitdir = os.path.join(self.tempdir, 'gitshallow') |
1391 | bb.utils.mkdirhier(self.gitdir) | 1395 | bb.utils.mkdirhier(self.gitdir) |
1392 | bb.process.run('git init', cwd=self.gitdir) | 1396 | bb.process.run('git init', cwd=self.gitdir) |
1397 | bb.process.run('git config user.email "you@example.com"', cwd=self.gitdir) | ||
1398 | bb.process.run('git config user.name "Your Name"', cwd=self.gitdir) | ||
1393 | 1399 | ||
1394 | def assertRefs(self, expected_refs): | 1400 | def assertRefs(self, expected_refs): |
1395 | actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines() | 1401 | actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines() |
@@ -1513,6 +1519,8 @@ class GitShallowTest(FetcherTest): | |||
1513 | 1519 | ||
1514 | bb.utils.mkdirhier(self.srcdir) | 1520 | bb.utils.mkdirhier(self.srcdir) |
1515 | self.git('init', cwd=self.srcdir) | 1521 | self.git('init', cwd=self.srcdir) |
1522 | self.git('config user.email "you@example.com"', cwd=self.srcdir) | ||
1523 | self.git('config user.name "Your Name"', cwd=self.srcdir) | ||
1516 | self.d.setVar('WORKDIR', self.tempdir) | 1524 | self.d.setVar('WORKDIR', self.tempdir) |
1517 | self.d.setVar('S', self.gitdir) | 1525 | self.d.setVar('S', self.gitdir) |
1518 | self.d.delVar('PREMIRRORS') | 1526 | self.d.delVar('PREMIRRORS') |
@@ -1746,6 +1754,8 @@ class GitShallowTest(FetcherTest): | |||
1746 | smdir = os.path.join(self.tempdir, 'gitsubmodule') | 1754 | smdir = os.path.join(self.tempdir, 'gitsubmodule') |
1747 | bb.utils.mkdirhier(smdir) | 1755 | bb.utils.mkdirhier(smdir) |
1748 | self.git('init', cwd=smdir) | 1756 | self.git('init', cwd=smdir) |
1757 | self.git('config user.email "you@example.com"', cwd=smdir) | ||
1758 | self.git('config user.name "Your Name"', cwd=smdir) | ||
1749 | # Make this look like it was cloned from a remote... | 1759 | # Make this look like it was cloned from a remote... |
1750 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) | 1760 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) |
1751 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) | 1761 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) |
@@ -1776,6 +1786,8 @@ class GitShallowTest(FetcherTest): | |||
1776 | smdir = os.path.join(self.tempdir, 'gitsubmodule') | 1786 | smdir = os.path.join(self.tempdir, 'gitsubmodule') |
1777 | bb.utils.mkdirhier(smdir) | 1787 | bb.utils.mkdirhier(smdir) |
1778 | self.git('init', cwd=smdir) | 1788 | self.git('init', cwd=smdir) |
1789 | self.git('config user.email "you@example.com"', cwd=smdir) | ||
1790 | self.git('config user.name "Your Name"', cwd=smdir) | ||
1779 | # Make this look like it was cloned from a remote... | 1791 | # Make this look like it was cloned from a remote... |
1780 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) | 1792 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) |
1781 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) | 1793 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) |
@@ -1818,7 +1830,7 @@ class GitShallowTest(FetcherTest): | |||
1818 | self.git('annex init', cwd=self.srcdir) | 1830 | self.git('annex init', cwd=self.srcdir) |
1819 | open(os.path.join(self.srcdir, 'c'), 'w').close() | 1831 | open(os.path.join(self.srcdir, 'c'), 'w').close() |
1820 | self.git('annex add c', cwd=self.srcdir) | 1832 | self.git('annex add c', cwd=self.srcdir) |
1821 | self.git('commit -m annex-c -a', cwd=self.srcdir) | 1833 | self.git('commit --author "Foo Bar <foo@bar>" -m annex-c -a', cwd=self.srcdir) |
1822 | bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex')) | 1834 | bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex')) |
1823 | 1835 | ||
1824 | uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir | 1836 | uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir |
@@ -2094,6 +2106,8 @@ class GitLfsTest(FetcherTest): | |||
2094 | 2106 | ||
2095 | bb.utils.mkdirhier(self.srcdir) | 2107 | bb.utils.mkdirhier(self.srcdir) |
2096 | self.git('init', cwd=self.srcdir) | 2108 | self.git('init', cwd=self.srcdir) |
2109 | self.git('config user.email "you@example.com"', cwd=self.srcdir) | ||
2110 | self.git('config user.name "Your Name"', cwd=self.srcdir) | ||
2097 | with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs: | 2111 | with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs: |
2098 | attrs.write('*.mp3 filter=lfs -text') | 2112 | attrs.write('*.mp3 filter=lfs -text') |
2099 | self.git(['add', '.gitattributes'], cwd=self.srcdir) | 2113 | self.git(['add', '.gitattributes'], cwd=self.srcdir) |