From 24433ce8f9e091f04a18d2753347f32fb0860999 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Mon, 19 Feb 2024 02:28:28 +0100 Subject: lib/oe/patch: Make extractPatches() not extract ignored commits If a commit is marked with "%% ignore" it means it is used by devtool to keep track of changes to the source code that are not the result of running do_patch(). These changes need to actually be ignored when extracting the patches as they typically make no sense as actual patches in a recipe. This also adds a new test for oe-selftest that verifies that there are no patches generated from ignored commits. (From OE-Core rev: c3d43de7e54189bf09fbe8e87ddb976e42ebf531) Signed-off-by: Peter Kjellerstedt Signed-off-by: Richard Purdie --- meta/lib/oe/patch.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'meta/lib/oe/patch.py') diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index d5ad4f3dc1..70cdb1d9c0 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -474,9 +474,9 @@ class GitApplyTree(PatchTree): out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name)) if out: for srcfile in out.split(): + outfile = os.path.basename(srcfile) for encoding in ['utf-8', 'latin-1']: patchlines = [] - outfile = None try: with open(srcfile, 'r', encoding=encoding, newline='') as f: for line in f: @@ -484,7 +484,8 @@ class GitApplyTree(PatchTree): outfile = line.split()[-1].strip() continue if line.startswith(GitApplyTree.ignore_commit_prefix): - continue + outfile = None + break patchlines.append(line) except UnicodeDecodeError: continue @@ -492,12 +493,11 @@ class GitApplyTree(PatchTree): else: raise PatchError('Unable to find a character encoding to decode %s' % srcfile) - if not outfile: - outfile = os.path.basename(srcfile) - bb.utils.mkdirhier(os.path.join(outdir, name)) - with open(os.path.join(outdir, name, outfile), 'w') as of: - for line in patchlines: - of.write(line) + if outfile: + bb.utils.mkdirhier(os.path.join(outdir, name)) + with open(os.path.join(outdir, name, outfile), 'w') as of: + for line in patchlines: + of.write(line) finally: shutil.rmtree(tempdir) -- cgit v1.2.3-54-g00ecf