commit 43f934a98c54a5de1fc9f707b8ffbf6d4e9250c0
parent c9b293714772ace8988dead2381cfafdc9b86cd8
Author: Michael Froman <mfroman@mozilla.com>
Date: Mon, 24 Nov 2025 02:43:47 +0000
Bug 2001165 - reuse the prefixed file name code for both types of patches. r=dbaker DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D273638
Diffstat:
1 file changed, 26 insertions(+), 24 deletions(-)
diff --git a/dom/media/webrtc/third_party_build/save_patch_stack.py b/dom/media/webrtc/third_party_build/save_patch_stack.py
@@ -37,6 +37,26 @@ def build_repo_name_from_path(input_dir):
return output_dir
+def write_patch_files_with_prefix(
+ github_path,
+ patch_directory,
+ start_commit_sha,
+ end_commit_sha,
+ prefix,
+):
+ cmd = f"git format-patch --keep-subject --no-signature --output-directory {patch_directory} {start_commit_sha}..{end_commit_sha}"
+ run_git(cmd, github_path)
+
+ # remove the commit summary from the file name and add provided prefix
+ patches_to_rename = os.listdir(patch_directory)
+ for file in patches_to_rename:
+ shortened_name = re.sub(r"^(\d\d\d\d)-.*\.patch", f"{prefix}\\1.patch", file)
+ os.rename(
+ os.path.join(patch_directory, file),
+ os.path.join(patch_directory, shortened_name),
+ )
+
+
def save_patch_stack(
github_path,
github_branch,
@@ -92,32 +112,14 @@ def save_patch_stack(
# Normal commits are the Mozilla patch-stack commits.
# write only the pre-stack patches out
- cmd = f"git format-patch --keep-subject --no-signature --output-directory {patch_directory} {merge_base}..{base_commit_sha}^"
- stdout_lines = run_git(cmd, github_path)
-
- # remove the commit summary from the file name - also prefix the pre-stack
- # patches with 'p'
- patches_to_rename = os.listdir(patch_directory)
- for file in patches_to_rename:
- shortened_name = re.sub(r"^(\d\d\d\d)-.*\.patch", "p\\1.patch", file)
- os.rename(
- os.path.join(patch_directory, file),
- os.path.join(patch_directory, shortened_name),
- )
+ write_patch_files_with_prefix(
+ github_path, patch_directory, f"{merge_base}", f"{base_commit_sha}^", "p"
+ )
# write only the "normal" stack patches out
- cmd = f"git format-patch --keep-subject --no-signature --output-directory {patch_directory} {base_commit_sha}^..{github_branch}"
- run_git(cmd, github_path)
-
- # remove the commit summary from the file name - also prefix the "normal"
- # patches with 's'
- patches_to_rename = os.listdir(patch_directory)
- for file in patches_to_rename:
- shortened_name = re.sub(r"^(\d\d\d\d)-.*\.patch", "s\\1.patch", file)
- os.rename(
- os.path.join(patch_directory, file),
- os.path.join(patch_directory, shortened_name),
- )
+ write_patch_files_with_prefix(
+ github_path, patch_directory, f"{base_commit_sha}^", f"{github_branch}", "s"
+ )
# remove the unhelpful first line of the patch files that only
# causes diff churn. For reasons why we can't skip creating backup