From bd44f81abedff35ec2ff7c3d4f332ec6484c9469 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Mon, 13 Apr 2020 09:46:15 -0700 Subject: [PATCH] build: improve patch filename remembering (#23070) --- script/lib/patches.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/lib/patches.py b/script/lib/patches.py index 92533b45dab9d..c5865c2e70b9b 100644 --- a/script/lib/patches.py +++ b/script/lib/patches.py @@ -7,10 +7,12 @@ def read_patch(patch_dir, patch_filename): """Read a patch from |patch_dir/filename| and amend the commit message with metadata about the patch file it came from.""" ret = [] + added_filename_line = False with open(os.path.join(patch_dir, patch_filename)) as f: for l in f.readlines(): - if l.startswith('diff -'): + if not added_filename_line and (l.startswith('diff -') or l.startswith('---')): ret.append('Patch-Filename: {}\n'.format(patch_filename)) + added_filename_line = True ret.append(l) return ''.join(ret)