Fix the WPT exporter (#30870)

* Fix the WPT exporter

* apply fixes by @mrobinson

* fix mach test-scripts on NixOS

* rename main_branch_name to default_branch
This commit is contained in:
Delan Azabani 2023-12-15 19:05:00 +08:00 committed by GitHub
parent 29eb4878ed
commit 0be30b30ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 11 deletions

View file

@ -19,6 +19,7 @@ import dataclasses
import json
import logging
import re
import shutil
import subprocess
from typing import Callable, Optional
@ -50,8 +51,12 @@ class LocalGitRepo:
self.path = path
self.sync = sync
# We pass env to subprocess, which may clobber PATH, so we need to find
# git in advance and run the subprocess by its absolute path.
self.git_path = shutil.which("git")
def run_without_encoding(self, *args, env: dict = {}):
command_line = ["git"] + list(args)
command_line = [self.git_path] + list(args)
logging.info(" → Execution (cwd='%s'): %s",
self.path, " ".join(command_line))
@ -142,9 +147,9 @@ class WPTSync:
suppress_force_push: bool = False
def __post_init__(self):
self.servo = GithubRepository(self, self.servo_repo)
self.wpt = GithubRepository(self, self.wpt_repo)
self.downstream_wpt = GithubRepository(self, self.downstream_wpt_repo)
self.servo = GithubRepository(self, self.servo_repo, "main")
self.wpt = GithubRepository(self, self.wpt_repo, "master")
self.downstream_wpt = GithubRepository(self, self.downstream_wpt_repo, "master")
self.local_servo_repo = LocalGitRepo(self.servo_path, self)
self.local_wpt_repo = LocalGitRepo(self.wpt_path, self)

View file

@ -55,9 +55,10 @@ class GithubRepository:
This class allows interacting with a single GitHub repository.
"""
def __init__(self, sync: WPTSync, repo: str):
def __init__(self, sync: WPTSync, repo: str, default_branch: str):
self.sync = sync
self.repo = repo
self.default_branch = default_branch
self.org = repo.split("/")[0]
self.pulls_url = f"repos/{self.repo}/pulls"
@ -105,7 +106,7 @@ class GithubRepository:
data = {
"title": title,
"head": branch.get_pr_head_reference_for_repo(self),
"base": "main",
"base": self.default_branch,
"body": body,
"maintainer_can_modify": False,
}

View file

@ -190,7 +190,7 @@ class CreateOrUpdateBranchForPRStep(Step):
return branch_name
finally:
try:
run.sync.local_wpt_repo.run("checkout", "main")
run.sync.local_wpt_repo.run("checkout", "master")
run.sync.local_wpt_repo.run("branch", "-D", branch_name)
except Exception:
pass

View file

@ -644,17 +644,17 @@ def setUpModule():
suppress_force_push=True,
)
def setup_mock_repo(repo_name, local_repo):
def setup_mock_repo(repo_name, local_repo, default_branch: str):
subprocess.check_output(
["cp", "-R", "-p", os.path.join(TESTS_DIR, repo_name), local_repo.path])
local_repo.run("init", "-b", "main")
local_repo.run("init", "-b", default_branch)
local_repo.run("add", ".")
local_repo.run("commit", "-a", "-m", "Initial commit")
logging.info("=" * 80)
logging.info("Setting up mock repositories")
setup_mock_repo("servo-mock", SYNC.local_servo_repo)
setup_mock_repo("wpt-mock", SYNC.local_wpt_repo)
setup_mock_repo("servo-mock", SYNC.local_servo_repo, "main")
setup_mock_repo("wpt-mock", SYNC.local_wpt_repo, "master")
logging.info("=" * 80)