From 1f8f61d5cd6f4cad42bf89ceadd654d82dea4472 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 13 Nov 2023 22:01:03 -0600 Subject: [PATCH 1/3] Process pull requets directly from mbox Rather than letting b4 fetch a second time use the same one that was already downloaded. Signed-off-by: Mario Limonciello --- contrib/process_linux_firmware.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/process_linux_firmware.py b/contrib/process_linux_firmware.py index 7d867a8d..b1d98222 100755 --- a/contrib/process_linux_firmware.py +++ b/contrib/process_linux_firmware.py @@ -142,14 +142,15 @@ def delete_branch(branch): quiet_cmd(["git", "branch", "-D", branch]) -def process_pr(url, num, remote): +def process_pr(mbox, num, remote): branch = "robot/pr-{}-{}".format(num, int(time.time())) - cmd = ["b4", "pr", "-b", branch, url] - try: - quiet_cmd(cmd) - except subprocess.CalledProcessError: - logging.warning("Failed to apply PR") - return None + + cmd = ["b4", "--debug", "pr", "-b", branch, "-"] + logging.debug("Running {}".format(cmd)) + p = subprocess.Popen( + cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) + stdout, stderr = p.communicate(mbox.encode("utf-8")) # determine if it worked (we can't tell unfortunately by return code) cmd = ["git", "branch", "--list", branch] @@ -244,7 +245,6 @@ def process_database(conn, remote): # loop over all unprocessed urls for row in rows: - branch = None msg = "Processing ({}%)".format(round(num / len(rows) * 100)) print(msg, end="\r", flush=True) @@ -260,7 +260,7 @@ def process_database(conn, remote): if classification == ContentType.PULL_REQUEST: logging.debug("Processing PR ({})".format(row[0])) - branch = process_pr(row[0], num, remote) + branch = process_pr(mbox, num, remote) if classification == ContentType.SPAM: logging.debug("Marking spam ({})".format(row[0])) From 05ac293be9443e7748c0d62207e331ce3b6464a2 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 13 Nov 2023 22:01:52 -0600 Subject: [PATCH 2/3] Add extra debugging output when processing pull requests Signed-off-by: Mario Limonciello --- contrib/process_linux_firmware.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/process_linux_firmware.py b/contrib/process_linux_firmware.py index b1d98222..46432a2d 100755 --- a/contrib/process_linux_firmware.py +++ b/contrib/process_linux_firmware.py @@ -151,6 +151,10 @@ def process_pr(mbox, num, remote): cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) stdout, stderr = p.communicate(mbox.encode("utf-8")) + for line in stdout.splitlines(): + logging.debug(line.decode("utf-8")) + for line in stderr.splitlines(): + logging.debug(line.decode("utf-8")) # determine if it worked (we can't tell unfortunately by return code) cmd = ["git", "branch", "--list", branch] @@ -158,6 +162,8 @@ def process_pr(mbox, num, remote): result = subprocess.check_output(cmd) if result: + for line in result.splitlines(): + logging.debug(line.decode("utf-8")) logging.info("Forwarding PR for {}".format(branch)) if remote: create_pr(remote, branch) From d011ba69ebb22867aade9725cd36d6d0ab72dfe5 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 13 Nov 2023 22:02:26 -0600 Subject: [PATCH 3/3] Add a workaround for gitlab.freedesktop.org pull requests Some of these pull requests are submitted using git protocol in the pull request which b4 won't be able to handle. Manually swap out for the https protocol. Signed-off-by: Mario Limonciello --- contrib/process_linux_firmware.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/process_linux_firmware.py b/contrib/process_linux_firmware.py index 46432a2d..668e35c0 100755 --- a/contrib/process_linux_firmware.py +++ b/contrib/process_linux_firmware.py @@ -145,6 +145,13 @@ def delete_branch(branch): def process_pr(mbox, num, remote): branch = "robot/pr-{}-{}".format(num, int(time.time())) + # manual fixup for PRs from drm firmware repo + if "git@gitlab.freedesktop.org:drm/firmware.git" in mbox: + mbox = mbox.replace( + "git@gitlab.freedesktop.org:drm/firmware.git", + "https://gitlab.freedesktop.org/drm/firmware.git", + ) + cmd = ["b4", "--debug", "pr", "-b", branch, "-"] logging.debug("Running {}".format(cmd)) p = subprocess.Popen(