summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oe/patch.py11
-rw-r--r--meta/lib/oeqa/selftest/cases/bbtests.py19
2 files changed, 25 insertions, 5 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 950fe723dc..9034fcae03 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -304,14 +304,19 @@ class GitApplyTree(PatchTree):
304 304
305 def _isInitialized(self): 305 def _isInitialized(self):
306 cmd = "git rev-parse --show-toplevel" 306 cmd = "git rev-parse --show-toplevel"
307 (status, output) = subprocess.getstatusoutput(cmd.split()) 307 try:
308 output = runcmd(cmd.split(), self.dir).strip()
309 except CmdError as err:
310 ## runcmd returned non-zero which most likely means 128
311 ## Not a git directory
312 return False
308 ## Make sure repo is in builddir to not break top-level git repos 313 ## Make sure repo is in builddir to not break top-level git repos
309 return status == 0 and os.path.samedir(output, self.dir) 314 return os.path.samefile(output, self.dir)
310 315
311 def _initRepo(self): 316 def _initRepo(self):
312 runcmd("git init".split(), self.dir) 317 runcmd("git init".split(), self.dir)
313 runcmd("git add .".split(), self.dir) 318 runcmd("git add .".split(), self.dir)
314 runcmd("git commit -a --allow-empty -m Patching_started".split(), self.dir) 319 runcmd("git commit -a --allow-empty -m bitbake_patching_started".split(), self.dir)
315 320
316 @staticmethod 321 @staticmethod
317 def extractPatchHeader(patchfile): 322 def extractPatchHeader(patchfile):
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index ce72c4bcc6..35ad9f3cd6 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -307,11 +307,26 @@ INHERIT:remove = \"report-error\"
307 src = get_bb_var("SRC_URI",test_recipe) 307 src = get_bb_var("SRC_URI",test_recipe)
308 gitscm = re.search("git://", src) 308 gitscm = re.search("git://", src)
309 self.assertFalse(gitscm, "test_git_patchtool pre-condition failed: {} test recipe contains git repo!".format(test_recipe)) 309 self.assertFalse(gitscm, "test_git_patchtool pre-condition failed: {} test recipe contains git repo!".format(test_recipe))
310 result = bitbake('man-db -c patch', ignore_status=False) 310 result = bitbake('{} -c patch'.format(test_recipe), ignore_status=False)
311 fatal = re.search("fatal: not a git repository (or any of the parent directories)", result.output) 311 fatal = re.search("fatal: not a git repository (or any of the parent directories)", result.output)
312 self.assertFalse(fatal, "Failed to patch using PATCHTOOL=\"git\"") 312 self.assertFalse(fatal, "Failed to patch using PATCHTOOL=\"git\"")
313 self.delete_recipeinc(test_recipe) 313 self.delete_recipeinc(test_recipe)
314 bitbake('-cclean man-db') 314 bitbake('-cclean {}'.format(test_recipe))
315
316 def test_git_patchtool2(self):
317 """ Test if PATCHTOOL=git works with git repo and doesn't reinitialize it
318 """
319 test_recipe = "gitrepotest"
320 src = get_bb_var("SRC_URI",test_recipe)
321 gitscm = re.search("git://", src)
322 self.assertTrue(gitscm, "test_git_patchtool pre-condition failed: {} test recipe doesn't contains git repo!".format(test_recipe))
323 result = bitbake('{} -c patch'.format(test_recipe), ignore_status=False)
324 srcdir = get_bb_var('S', test_recipe)
325 result = runCmd("git log", cwd = srcdir)
326 self.assertFalse("bitbake_patching_started" in result.output, msg = "Repository has been reinitialized. {}".format(srcdir))
327 self.delete_recipeinc(test_recipe)
328 bitbake('-cclean {}'.format(test_recipe))
329
315 330
316 def test_git_unpack_nonetwork(self): 331 def test_git_unpack_nonetwork(self):
317 """ 332 """