diff options
author | Simon Glass <sjg@chromium.org> | 2025-03-28 07:02:20 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-04-10 11:57:56 -0600 |
commit | 60218f07f357aeae34b524f0cdf2e512bda44645 (patch) | |
tree | 920ee8a44559fc0e6ff976ba29920d622c87c9bc /tools/patman/func_test.py | |
parent | 5a7ad313a12e9667001a926f55c9e4516f128638 (diff) |
patman: Show base commit on each patch when no cover letter
If a series is sent without a cover letter, there is no indication of
the base commit. Add support for this, since single patches of small
series may not always have a cover letter.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/func_test.py')
-rw-r--r-- | tools/patman/func_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 44eba2cdbb7..720746e21f5 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -357,6 +357,31 @@ Changes in v2: expected = expected.splitlines() self.assertEqual(expected, lines[start:(start+len(expected))]) + def test_base_commit(self): + """Test adding a base commit with no cover letter""" + orig_text = self._get_text('test01.txt') + pos = orig_text.index('commit 5ab48490f03051875ab13d288a4bf32b507d76fd') + text = orig_text[:pos] + series = patchstream.get_metadata_for_test(text) + series.base_commit = Commit('1a44532') + series.branch = 'mybranch' + cover_fname, args = self._create_patches_for_test(series) + self.assertFalse(cover_fname) + with capture_sys_output() as out: + patchstream.fix_patches(series, args, insert_base_commit=True) + self.assertEqual('Cleaned 1 patch\n', out[0].getvalue()) + lines = tools.read_file(args[0], binary=False).splitlines() + pos = lines.index('-- ') + + # We expect these lines at the end: + # -- (with trailing space) + # 2.7.4 + # (empty) + # base-commit: xxx + # branch: xxx + self.assertEqual('base-commit: 1a44532', lines[pos + 3]) + self.assertEqual('branch: mybranch', lines[pos + 4]) + def make_commit_with_file(self, subject, body, fname, text): """Create a file and add it to the git repo with a new commit @@ -527,6 +552,11 @@ complicated as possible''') self.assertEqual(f'base-commit: {base}', lines[0]) self.assertEqual('branch: second', lines[1]) + # Make sure that the base-commit is not present when it is in the + # cover letter + for fname in patch_files: + self.assertNotIn(b'base-commit:', tools.read_file(fname)) + # Check that it can skip patches at the end with capture_sys_output() as _: _, cover_fname, patch_files = control.prepare_patches( |