commit 1032003ae035b0bf934781ec6253d2757507cbb7
parent eec2ce52b9109e821ed96ff25ec11592147a7b30
Author: Erich Gubler <erichdongubler@gmail.com>
Date: Wed, 8 Oct 2025 16:27:12 +0000
Bug 1992509 - feat(mach): add `--vcs-diff` to `mach vendor rust` r=supply-chain-reviewers,glandium
Add a `--vcs-diff` option to `mach vendor rust` that prints a diff of
"uncommitted" changes after the main vendoring operation. On success,
this is expected to be empty.
This will be consumed in a subsequent patch, where we upload this sort
of diff to Taskcluster jobs so that contributors can use it to fix their
patches and move on.
Differential Revision: https://phabricator.services.mozilla.com/D267478
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/python/mozbuild/mozbuild/vendor/mach_commands.py b/python/mozbuild/mozbuild/vendor/mach_commands.py
@@ -3,6 +3,7 @@
# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
import logging
+import shutil
import sys
from mach.decorators import Command, CommandArgument, SubCommand
@@ -208,15 +209,23 @@ Please commit or stash these changes before vendoring, or re-run with `--ignore-
"--issues-json",
help="Path to a code-review issues.json file to write out",
)
+@CommandArgument(
+ "--vcs-diff",
+ help="Path to a diff. file to write out, if there are uncommitted changes present after running",
+)
def vendor_rust(command_context, **kwargs):
from mozbuild.vendor.vendor_rust import VendorRust
vendor_command = command_context._spawn(VendorRust)
issues_json = kwargs.pop("issues_json", None)
+ vcs_diff = kwargs.pop("vcs_diff", None)
ok = vendor_command.vendor(**kwargs)
if issues_json:
with open(issues_json, "w") as fh:
fh.write(vendor_command.serialize_issues_json())
+ if vcs_diff:
+ with open(vcs_diff, "w", encoding="utf-8", newline="\n") as fh:
+ shutil.copyfileobj(vendor_command.generate_diff_stream(), fh)
if ok:
sys.exit(0)
else:
diff --git a/python/mozbuild/mozbuild/vendor/vendor_rust.py b/python/mozbuild/mozbuild/vendor/vendor_rust.py
@@ -178,6 +178,9 @@ class VendorRust(MozbuildObject):
}
)
+ def generate_diff_stream(self):
+ return self.repository.diff_stream()
+
def log(self, level, action, params, format_str):
if level >= logging.WARNING:
self._issues.append((level, format_str.format(**params)))