tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f98ea77e94e23e92c878942e12a2c865aa880fd9
parent 76fe8d5b880280a09e0f0ef16209789a6681ac6e
Author: Suhaib Mujahid <suhaibmujahid@gmail.com>
Date:   Tue, 18 Nov 2025 18:28:58 +0000

Bug 2000697 - Handle empty git diff in test recommendation flow. r=marco

Updated GitRepository.get_patch_for_uncommitted_changes to return an empty string if there are no uncommitted changes. Modified the test command to print a message and exit early if no local changes are detected, preventing unnecessary BugBug queries.

Differential Revision: https://phabricator.services.mozilla.com/D272960

Diffstat:
Mpython/mozversioncontrol/mozversioncontrol/repo/git.py | 6+++++-
Mtesting/mach_commands.py | 3+++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/python/mozversioncontrol/mozversioncontrol/repo/git.py b/python/mozversioncontrol/mozversioncontrol/repo/git.py @@ -705,6 +705,10 @@ class GitRepository(Repository): Generate a git format-patch style patch of all uncommitted changes in the working directory. """ + diff = self._run("diff", "--no-color", "HEAD") + if not diff.strip(): + return "" + if not date: date = datetime.now() @@ -717,7 +721,7 @@ class GitRepository(Repository): f"From: {name} <{email}>", f"Date: {formatted_date}", f"Subject: {message}" "\n---\n", - self._run("diff", "--no-color", "HEAD"), + diff, ] return "\n".join(patch) diff --git a/testing/mach_commands.py b/testing/mach_commands.py @@ -413,6 +413,9 @@ def test(command_context, what, extra_args, **log_args): repo.get_patch_for_uncommitted_changes(), ] ) + if not patch.strip(): + print("No local changes detected; no tests to run.") + return 1 print( f"Querying BugBug for test recommendations... (based on changes after {base_commit[:8]})"