mirror of
https://git.proxmox.com/git/mirror_linux-firmware
synced 2025-05-24 22:57:40 +00:00
Merge branch 'mlimonci/robot-pr-improvements' into 'main'
Fixups for robot script to handle pull requests better See merge request kernel-firmware/linux-firmware!58
This commit is contained in:
commit
b72eeb6039
@ -142,14 +142,26 @@ def delete_branch(branch):
|
|||||||
quiet_cmd(["git", "branch", "-D", 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()))
|
branch = "robot/pr-{}-{}".format(num, int(time.time()))
|
||||||
cmd = ["b4", "pr", "-b", branch, url]
|
|
||||||
try:
|
# manual fixup for PRs from drm firmware repo
|
||||||
quiet_cmd(cmd)
|
if "git@gitlab.freedesktop.org:drm/firmware.git" in mbox:
|
||||||
except subprocess.CalledProcessError:
|
mbox = mbox.replace(
|
||||||
logging.warning("Failed to apply PR")
|
"git@gitlab.freedesktop.org:drm/firmware.git",
|
||||||
return None
|
"https://gitlab.freedesktop.org/drm/firmware.git",
|
||||||
|
)
|
||||||
|
|
||||||
|
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"))
|
||||||
|
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)
|
# determine if it worked (we can't tell unfortunately by return code)
|
||||||
cmd = ["git", "branch", "--list", branch]
|
cmd = ["git", "branch", "--list", branch]
|
||||||
@ -157,6 +169,8 @@ def process_pr(url, num, remote):
|
|||||||
result = subprocess.check_output(cmd)
|
result = subprocess.check_output(cmd)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
|
for line in result.splitlines():
|
||||||
|
logging.debug(line.decode("utf-8"))
|
||||||
logging.info("Forwarding PR for {}".format(branch))
|
logging.info("Forwarding PR for {}".format(branch))
|
||||||
if remote:
|
if remote:
|
||||||
create_pr(remote, branch)
|
create_pr(remote, branch)
|
||||||
@ -244,7 +258,6 @@ def process_database(conn, remote):
|
|||||||
|
|
||||||
# loop over all unprocessed urls
|
# loop over all unprocessed urls
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
|
||||||
branch = None
|
branch = None
|
||||||
msg = "Processing ({}%)".format(round(num / len(rows) * 100))
|
msg = "Processing ({}%)".format(round(num / len(rows) * 100))
|
||||||
print(msg, end="\r", flush=True)
|
print(msg, end="\r", flush=True)
|
||||||
@ -260,7 +273,7 @@ def process_database(conn, remote):
|
|||||||
|
|
||||||
if classification == ContentType.PULL_REQUEST:
|
if classification == ContentType.PULL_REQUEST:
|
||||||
logging.debug("Processing PR ({})".format(row[0]))
|
logging.debug("Processing PR ({})".format(row[0]))
|
||||||
branch = process_pr(row[0], num, remote)
|
branch = process_pr(mbox, num, remote)
|
||||||
|
|
||||||
if classification == ContentType.SPAM:
|
if classification == ContentType.SPAM:
|
||||||
logging.debug("Marking spam ({})".format(row[0]))
|
logging.debug("Marking spam ({})".format(row[0]))
|
||||||
|
Loading…
Reference in New Issue
Block a user