mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
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: 57c0811f1ee19b6619f4840a39e01e3cb98c34c4)
Signed-off-by: Mikko Rapeli <mikko.rapeli@bmw.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
7ea37b9291
commit
490fb73e34
@@ -679,6 +679,8 @@ class FetcherLocalTest(FetcherTest):
|
|||||||
prefix='gitfetch_localusehead_')
|
prefix='gitfetch_localusehead_')
|
||||||
src_dir = os.path.abspath(src_dir)
|
src_dir = os.path.abspath(src_dir)
|
||||||
bb.process.run("git init", cwd=src_dir)
|
bb.process.run("git init", cwd=src_dir)
|
||||||
|
bb.process.run("git config user.email 'you@example.com'", cwd=src_dir)
|
||||||
|
bb.process.run("git config user.name 'Your Name'", cwd=src_dir)
|
||||||
bb.process.run("git commit --allow-empty -m'Dummy commit'",
|
bb.process.run("git commit --allow-empty -m'Dummy commit'",
|
||||||
cwd=src_dir)
|
cwd=src_dir)
|
||||||
# Use other branch than master
|
# Use other branch than master
|
||||||
@@ -705,6 +707,8 @@ class FetcherLocalTest(FetcherTest):
|
|||||||
prefix='gitfetch_localusehead_')
|
prefix='gitfetch_localusehead_')
|
||||||
src_dir = os.path.abspath(src_dir)
|
src_dir = os.path.abspath(src_dir)
|
||||||
bb.process.run("git init", cwd=src_dir)
|
bb.process.run("git init", cwd=src_dir)
|
||||||
|
bb.process.run("git config user.email 'you@example.com'", cwd=src_dir)
|
||||||
|
bb.process.run("git config user.name 'Your Name'", cwd=src_dir)
|
||||||
bb.process.run("git commit --allow-empty -m'Dummy commit'",
|
bb.process.run("git commit --allow-empty -m'Dummy commit'",
|
||||||
cwd=src_dir)
|
cwd=src_dir)
|
||||||
# Use other branch than master
|
# Use other branch than master
|
||||||
@@ -1390,6 +1394,8 @@ class GitMakeShallowTest(FetcherTest):
|
|||||||
self.gitdir = os.path.join(self.tempdir, 'gitshallow')
|
self.gitdir = os.path.join(self.tempdir, 'gitshallow')
|
||||||
bb.utils.mkdirhier(self.gitdir)
|
bb.utils.mkdirhier(self.gitdir)
|
||||||
bb.process.run('git init', cwd=self.gitdir)
|
bb.process.run('git init', cwd=self.gitdir)
|
||||||
|
bb.process.run('git config user.email "you@example.com"', cwd=self.gitdir)
|
||||||
|
bb.process.run('git config user.name "Your Name"', cwd=self.gitdir)
|
||||||
|
|
||||||
def assertRefs(self, expected_refs):
|
def assertRefs(self, expected_refs):
|
||||||
actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines()
|
actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines()
|
||||||
@@ -1513,6 +1519,8 @@ class GitShallowTest(FetcherTest):
|
|||||||
|
|
||||||
bb.utils.mkdirhier(self.srcdir)
|
bb.utils.mkdirhier(self.srcdir)
|
||||||
self.git('init', cwd=self.srcdir)
|
self.git('init', cwd=self.srcdir)
|
||||||
|
self.git('config user.email "you@example.com"', cwd=self.srcdir)
|
||||||
|
self.git('config user.name "Your Name"', cwd=self.srcdir)
|
||||||
self.d.setVar('WORKDIR', self.tempdir)
|
self.d.setVar('WORKDIR', self.tempdir)
|
||||||
self.d.setVar('S', self.gitdir)
|
self.d.setVar('S', self.gitdir)
|
||||||
self.d.delVar('PREMIRRORS')
|
self.d.delVar('PREMIRRORS')
|
||||||
@@ -1746,6 +1754,8 @@ class GitShallowTest(FetcherTest):
|
|||||||
smdir = os.path.join(self.tempdir, 'gitsubmodule')
|
smdir = os.path.join(self.tempdir, 'gitsubmodule')
|
||||||
bb.utils.mkdirhier(smdir)
|
bb.utils.mkdirhier(smdir)
|
||||||
self.git('init', cwd=smdir)
|
self.git('init', cwd=smdir)
|
||||||
|
self.git('config user.email "you@example.com"', cwd=smdir)
|
||||||
|
self.git('config user.name "Your Name"', cwd=smdir)
|
||||||
# Make this look like it was cloned from a remote...
|
# Make this look like it was cloned from a remote...
|
||||||
self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
|
self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
|
||||||
self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
|
self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
|
||||||
@@ -1776,6 +1786,8 @@ class GitShallowTest(FetcherTest):
|
|||||||
smdir = os.path.join(self.tempdir, 'gitsubmodule')
|
smdir = os.path.join(self.tempdir, 'gitsubmodule')
|
||||||
bb.utils.mkdirhier(smdir)
|
bb.utils.mkdirhier(smdir)
|
||||||
self.git('init', cwd=smdir)
|
self.git('init', cwd=smdir)
|
||||||
|
self.git('config user.email "you@example.com"', cwd=smdir)
|
||||||
|
self.git('config user.name "Your Name"', cwd=smdir)
|
||||||
# Make this look like it was cloned from a remote...
|
# Make this look like it was cloned from a remote...
|
||||||
self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
|
self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
|
||||||
self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
|
self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
|
||||||
@@ -1818,7 +1830,7 @@ class GitShallowTest(FetcherTest):
|
|||||||
self.git('annex init', cwd=self.srcdir)
|
self.git('annex init', cwd=self.srcdir)
|
||||||
open(os.path.join(self.srcdir, 'c'), 'w').close()
|
open(os.path.join(self.srcdir, 'c'), 'w').close()
|
||||||
self.git('annex add c', cwd=self.srcdir)
|
self.git('annex add c', cwd=self.srcdir)
|
||||||
self.git('commit -m annex-c -a', cwd=self.srcdir)
|
self.git('commit --author "Foo Bar <foo@bar>" -m annex-c -a', cwd=self.srcdir)
|
||||||
bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex'))
|
bb.process.run('chmod u+w -R %s' % os.path.join(self.srcdir, '.git', 'annex'))
|
||||||
|
|
||||||
uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir
|
uri = 'gitannex://%s;protocol=file;subdir=${S}' % self.srcdir
|
||||||
@@ -2094,6 +2106,8 @@ class GitLfsTest(FetcherTest):
|
|||||||
|
|
||||||
bb.utils.mkdirhier(self.srcdir)
|
bb.utils.mkdirhier(self.srcdir)
|
||||||
self.git('init', cwd=self.srcdir)
|
self.git('init', cwd=self.srcdir)
|
||||||
|
self.git('config user.email "you@example.com"', cwd=self.srcdir)
|
||||||
|
self.git('config user.name "Your Name"', cwd=self.srcdir)
|
||||||
with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs:
|
with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs:
|
||||||
attrs.write('*.mp3 filter=lfs -text')
|
attrs.write('*.mp3 filter=lfs -text')
|
||||||
self.git(['add', '.gitattributes'], cwd=self.srcdir)
|
self.git(['add', '.gitattributes'], cwd=self.srcdir)
|
||||||
|
|||||||
Reference in New Issue
Block a user