diff options
author | Mikko Rapeli <mikko.rapeli@bmw.de> | 2021-05-10 04:15:16 -1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-05-13 13:12:00 +0100 |
commit | ea63f713b3def2f3fa5da83ee39794fed3b2366c (patch) | |
tree | 8fa87004b5c35ae074d9b088fe8a435c60f2ca7a /bitbake | |
parent | 945b4ef084cb254643b425748d5e38c4f5908a9a (diff) | |
download | poky-ea63f713b3def2f3fa5da83ee39794fed3b2366c.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_no
r_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: e341afcce40edf8078661630af1e0a780e8c1910)
Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 9453c90d2b..9a4f5f11e2 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -845,6 +845,8 @@ class FetcherNetworkTest(FetcherTest): | |||
845 | prefix='gitfetch_localusehead_') | 845 | prefix='gitfetch_localusehead_') |
846 | src_dir = os.path.abspath(src_dir) | 846 | src_dir = os.path.abspath(src_dir) |
847 | bb.process.run("git init", cwd=src_dir) | 847 | bb.process.run("git init", cwd=src_dir) |
848 | bb.process.run("git config user.email 'you@example.com'", cwd=src_dir) | ||
849 | bb.process.run("git config user.name 'Your Name'", cwd=src_dir) | ||
848 | bb.process.run("git commit --allow-empty -m'Dummy commit'", | 850 | bb.process.run("git commit --allow-empty -m'Dummy commit'", |
849 | cwd=src_dir) | 851 | cwd=src_dir) |
850 | # Use other branch than master | 852 | # Use other branch than master |
@@ -1328,6 +1330,8 @@ class GitMakeShallowTest(FetcherTest): | |||
1328 | self.gitdir = os.path.join(self.tempdir, 'gitshallow') | 1330 | self.gitdir = os.path.join(self.tempdir, 'gitshallow') |
1329 | bb.utils.mkdirhier(self.gitdir) | 1331 | bb.utils.mkdirhier(self.gitdir) |
1330 | bb.process.run('git init', cwd=self.gitdir) | 1332 | bb.process.run('git init', cwd=self.gitdir) |
1333 | bb.process.run('git config user.email "you@example.com"', cwd=self.gitdir) | ||
1334 | bb.process.run('git config user.name "Your Name"', cwd=self.gitdir) | ||
1331 | 1335 | ||
1332 | def assertRefs(self, expected_refs): | 1336 | def assertRefs(self, expected_refs): |
1333 | actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines() | 1337 | actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines() |
@@ -1451,6 +1455,8 @@ class GitShallowTest(FetcherTest): | |||
1451 | 1455 | ||
1452 | bb.utils.mkdirhier(self.srcdir) | 1456 | bb.utils.mkdirhier(self.srcdir) |
1453 | self.git('init', cwd=self.srcdir) | 1457 | self.git('init', cwd=self.srcdir) |
1458 | self.git('config user.email "you@example.com"', cwd=self.srcdir) | ||
1459 | self.git('config user.name "Your Name"', cwd=self.srcdir) | ||
1454 | self.d.setVar('WORKDIR', self.tempdir) | 1460 | self.d.setVar('WORKDIR', self.tempdir) |
1455 | self.d.setVar('S', self.gitdir) | 1461 | self.d.setVar('S', self.gitdir) |
1456 | self.d.delVar('PREMIRRORS') | 1462 | self.d.delVar('PREMIRRORS') |
@@ -1684,6 +1690,8 @@ class GitShallowTest(FetcherTest): | |||
1684 | smdir = os.path.join(self.tempdir, 'gitsubmodule') | 1690 | smdir = os.path.join(self.tempdir, 'gitsubmodule') |
1685 | bb.utils.mkdirhier(smdir) | 1691 | bb.utils.mkdirhier(smdir) |
1686 | self.git('init', cwd=smdir) | 1692 | self.git('init', cwd=smdir) |
1693 | self.git('config user.email "you@example.com"', cwd=smdir) | ||
1694 | self.git('config user.name "Your Name"', cwd=smdir) | ||
1687 | # Make this look like it was cloned from a remote... | 1695 | # Make this look like it was cloned from a remote... |
1688 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) | 1696 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) |
1689 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) | 1697 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) |
@@ -1714,6 +1722,8 @@ class GitShallowTest(FetcherTest): | |||
1714 | smdir = os.path.join(self.tempdir, 'gitsubmodule') | 1722 | smdir = os.path.join(self.tempdir, 'gitsubmodule') |
1715 | bb.utils.mkdirhier(smdir) | 1723 | bb.utils.mkdirhier(smdir) |
1716 | self.git('init', cwd=smdir) | 1724 | self.git('init', cwd=smdir) |
1725 | self.git('config user.email "you@example.com"', cwd=smdir) | ||
1726 | self.git('config user.name "Your Name"', cwd=smdir) | ||
1717 | # Make this look like it was cloned from a remote... | 1727 | # Make this look like it was cloned from a remote... |
1718 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) | 1728 | self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir) |
1719 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) | 1729 | self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir) |
@@ -1756,7 +1766,7 @@ class GitShallowTest(FetcherTest): | |||
1756 | self.git('annex init', cwd=self.srcdir) | 1766 | self.git('annex init', cwd=self.srcdir) |
1757 | open(os.path.join(self.srcdir, 'c'), 'w').close() | 1767 | open(os.path.join(self.srcdir, 'c'), 'w').close() |
1758 | self.git('annex add c', cwd=self.srcdir) | 1768 | self.git('annex add c', cwd=self.srcdir) |
1759 | self.git('commit -m annex-c -a', cwd=self.srcdir) | 1769 | self.git('commit --author "Foo Bar <foo@bar>" -m annex-c -a', cwd=self.srcdir) |
1760 | bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex')) | 1770 | bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex')) |
1761 | 1771 | ||
1762 | uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir | 1772 | uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir |
@@ -2032,6 +2042,8 @@ class GitLfsTest(FetcherTest): | |||
2032 | 2042 | ||
2033 | bb.utils.mkdirhier(self.srcdir) | 2043 | bb.utils.mkdirhier(self.srcdir) |
2034 | self.git('init', cwd=self.srcdir) | 2044 | self.git('init', cwd=self.srcdir) |
2045 | self.git('config user.email "you@example.com"', cwd=self.srcdir) | ||
2046 | self.git('config user.name "Your Name"', cwd=self.srcdir) | ||
2035 | with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs: | 2047 | with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs: |
2036 | attrs.write('*.mp3 filter=lfs -text') | 2048 | attrs.write('*.mp3 filter=lfs -text') |
2037 | self.git(['add', '.gitattributes'], cwd=self.srcdir) | 2049 | self.git(['add', '.gitattributes'], cwd=self.srcdir) |