From 513728119a7cf520942bb22e40430cd73e0e8016 Mon Sep 17 00:00:00 2001 From: cdesouza-chromium Date: Wed, 25 Jun 2025 11:57:14 +0100 Subject: [PATCH] =?UTF-8?q?[plaster]=20Adding=20presubmit=20check=20for=20?= =?UTF-8?q?=F0=9F=A9=B9=20files=20(#29730)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [plaster] Adding presubmit check or 🩹 files This PR is a follow up on https://github.com/brave/brave-core/pull/29716. This PR adds a presubmit check that calls `plaster.py check`, and validates to make sure that any submitted plaster file is up-to-date with its patches, and applying correctly to the Chromium tree. There's still some work to be done regarding deleted plaster files, and what to do with a present patch file in such a case, but this is being tracked in a separate ticket. Resolves https://github.com/brave/brave-browser/issues/45058 --- PRESUBMIT.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 564e76c145d..bccc737205f 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -270,6 +270,37 @@ def CheckNewSourceFileWithoutGnChangeOnUpload(input_api, output_api): return [] +def CheckPlasterFiles(input_api, output_api): + """Checks that all Plaster files are up-to-date with their patches. + + This check ensures that all Plaster files in the repository are + synchronized with their corresponding patches in the Chromium repository. + This helps detecting unintentiional manual patching for sources that already + have a Plaster file. + """ + + affected_files = [] + for f in input_api.AffectedFiles(include_deletes=True): + local_path = f.LocalPath() + if (local_path.startswith("patches/") and local_path.endswith(".patch") + ) or (local_path.startswith("rewrite/") + and local_path.endswith(".toml")): + affected_files.append(local_path) + + if not affected_files: + return [] + + cmd = [input_api.python3_executable, 'tools/cr/plaster.py', 'check' + ] + affected_files + kwargs = {'cwd': input_api.PresubmitLocalPath()} + return input_api.RunTests([ + input_api.Command(name='plaster_check', + cmd=cmd, + kwargs=kwargs, + message=output_api.PresubmitError), + ]) + + # DON'T ADD NEW BRAVE CHECKS AFTER THIS LINE. # # This call inlines Chromium checks into current scope from src/PRESUBMIT.py. We