aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/tests/fetch.py
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2022-01-29 03:29:36 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-05 17:46:27 +0000
commita3a3a40b96c29051d97d0c96eb01784cbd1f5420 (patch)
treefbb34f959cecccafca9cf1cded86e50fdd875cd9 /lib/bb/tests/fetch.py
parent8c8b418c3e6f8ab2535ad405e8006ee1012f3484 (diff)
downloadbitbake-a3a3a40b96c29051d97d0c96eb01784cbd1f5420.tar.gz
tests/fetch: Only set the Git user name/email if they are not already set
If they are set, assume they are correct. Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tests/fetch.py')
-rw-r--r--lib/bb/tests/fetch.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index b1ff2c005..16a1b6f34 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -402,6 +402,13 @@ class FetcherTest(unittest.TestCase):
cwd = self.gitdir
return bb.process.run(cmd, cwd=cwd)[0]
+ def git_init(self, cwd=None):
+ self.git('init', cwd=cwd)
+ if not self.git(['config', 'user.email'], cwd=cwd):
+ self.git(['config', 'user.email', 'you@example.com'], cwd=cwd)
+ if not self.git(['config', 'user.name'], cwd=cwd):
+ self.git(['config', 'user.name', 'Your Name'], cwd=cwd)
+
class MirrorUriTest(FetcherTest):
replaceuris = {
@@ -709,9 +716,7 @@ class FetcherLocalTest(FetcherTest):
src_dir = tempfile.mkdtemp(dir=self.tempdir,
prefix='gitfetch_localusehead_')
self.gitdir = os.path.abspath(src_dir)
- self.git('init')
- self.git('config user.email "you@example.com"')
- self.git('config user.name "Your Name"')
+ self.git_init()
self.git(['commit', '--allow-empty', '-m', 'Dummy commit'])
# Use other branch than master
self.git(['checkout', '-b', 'my-devel'])
@@ -1443,9 +1448,7 @@ class GitMakeShallowTest(FetcherTest):
FetcherTest.setUp(self)
self.gitdir = os.path.join(self.tempdir, 'gitshallow')
bb.utils.mkdirhier(self.gitdir)
- self.git('init')
- self.git('config user.email "you@example.com"')
- self.git('config user.name "Your Name"')
+ self.git_init()
def assertRefs(self, expected_refs):
actual_refs = self.git(['for-each-ref', '--format=%(refname)']).splitlines()
@@ -1561,9 +1564,7 @@ class GitShallowTest(FetcherTest):
self.srcdir = os.path.join(self.tempdir, 'gitsource')
bb.utils.mkdirhier(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.git_init(cwd=self.srcdir)
self.d.setVar('WORKDIR', self.tempdir)
self.d.setVar('S', self.gitdir)
self.d.delVar('PREMIRRORS')
@@ -1788,9 +1789,7 @@ class GitShallowTest(FetcherTest):
smdir = os.path.join(self.tempdir, 'gitsubmodule')
bb.utils.mkdirhier(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)
+ self.git_init(cwd=smdir)
# 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.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
@@ -1820,9 +1819,7 @@ class GitShallowTest(FetcherTest):
smdir = os.path.join(self.tempdir, 'gitsubmodule')
bb.utils.mkdirhier(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)
+ self.git_init(cwd=smdir)
# 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.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
@@ -2140,9 +2137,7 @@ class GitLfsTest(FetcherTest):
self.d.setVar('AUTOREV', '${@bb.fetch2.get_autorev(d)}')
bb.utils.mkdirhier(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.git_init(cwd=self.srcdir)
with open(os.path.join(self.srcdir, '.gitattributes'), 'wt') as attrs:
attrs.write('*.mp3 filter=lfs -text')
self.git(['add', '.gitattributes'], cwd=self.srcdir)