From 3c76eb57719c7edfcf92f211f1f5085bcb565447 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Thu, 16 Apr 2026 11:51:13 +0200 Subject: [PATCH] Don't let note fetching stderr appear in logs unless fatal Without this, we let the fetch command write to the logs with a `fatal: failed to fetch` despite it, in fact, not being fatal. This silences it by capturing stderr instead. I also realized that because of copy/pasting I wasn't using `self.run` for ls-remote which is inconsistent and might fail in mysterious ways in gecko since it wasn't using `self.env` --- src/taskgraph/util/vcs.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/taskgraph/util/vcs.py b/src/taskgraph/util/vcs.py index d54a81acf..fbb18f266 100644 --- a/src/taskgraph/util/vcs.py +++ b/src/taskgraph/util/vcs.py @@ -612,15 +612,20 @@ def get_note( note = f"refs/notes/{note}" try: - self.run("fetch", remote, f"{note}:{note}") + self.run("fetch", remote, f"{note}:{note}", stderr=subprocess.PIPE) except subprocess.CalledProcessError: - ls = subprocess.run( - ["git", "ls-remote", "--exit-code", remote, note], - cwd=self.path, - capture_output=True, + ls_output = self.run( + "ls-remote", + "--exit-code", + remote, + note, + return_codes=(2,), + stderr=subprocess.PIPE, ) - # If the note doesn't exist, ignore the fetch failure - if ls.returncode == 2: + if not ls_output: + logger.info( + "Failed to fetch %s but the remote doesn't have it. Ignoring.", note + ) return None raise