From be26367fc36acaaeb48079038f13d20ba44bc52c Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 11:58:52 -0400 Subject: [PATCH 1/7] Update [ghstack-poisoned] --- src/ghstack/github.py | 14 ++++ src/ghstack/github_fake.py | 154 ++++++++++++++++++++++++++++++++++--- src/ghstack/github_real.py | 135 +++++++++++++++++++++++++++++--- src/ghstack/shell.py | 17 +++- 4 files changed, 299 insertions(+), 21 deletions(-) diff --git a/src/ghstack/github.py b/src/ghstack/github.py index 31343ca..c135269 100644 --- a/src/ghstack/github.py +++ b/src/ghstack/github.py @@ -95,3 +95,17 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: Returns: parsed JSON response """ pass + + @abstractmethod + async def arest(self, method: str, path: str, **kwargs: Any) -> Any: + """ + Send an async 'method' request to endpoint 'path'. + + Args: + method: 'GET', 'POST', etc. + path: relative URL path to access on endpoint + **kwargs: dictionary of JSON payload to send + + Returns: parsed JSON response + """ + pass diff --git a/src/ghstack/github_fake.py b/src/ghstack/github_fake.py index a54a3bb..e157445 100644 --- a/src/ghstack/github_fake.py +++ b/src/ghstack/github_fake.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 +import asyncio import dataclasses import os.path import re +import subprocess from dataclasses import dataclass from typing import Any, cast, Dict, List, NewType, Optional, Sequence @@ -168,16 +170,16 @@ def __init__(self, upstream_sh: Optional[ghstack.shell.Shell]) -> None: # operations depend on repository state (e.g., what # the headRef is at the time a PR is created), so # we need this information - self.upstream_sh.git("init", "--bare", "-b", "main") + self.upstream_sh.git("init", "--bare", "-b", "master") tree = self.upstream_sh.git("write-tree") commit = self.upstream_sh.git("commit-tree", tree, input="Initial commit") - self.upstream_sh.git("branch", "-f", "main", commit) + self.upstream_sh.git("branch", "-f", "master", commit) # We only update this when a PATCH changes the default # branch; hopefully that's fine? In any case, it should # work for now since currently we only ever access the name # of the default branch rather than other parts of its ref. - repo.defaultBranchRef = repo._make_ref(self, "main") + repo.defaultBranchRef = repo._make_ref(self, "master") @dataclass @@ -237,6 +239,32 @@ def _make_ref(self, state: GitHubState, refName: str) -> "Ref": ) return ref + async def _make_ref_async(self, state: GitHubState, refName: str) -> "Ref": + assert state.upstream_sh + proc = await asyncio.create_subprocess_exec( + "git", + "rev-parse", + refName, + cwd=state.upstream_sh.cwd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + out, _err = await proc.communicate() + if proc.returncode != 0: + raise RuntimeError(f"git rev-parse {refName} failed") + gitObject = GitObject( + id=state.next_id(), + oid=GitObjectID(out.decode(errors="backslashreplace").strip()), + _repository=self.id, + ) + ref = Ref( + id=state.next_id(), + name=refName, + _repository=self.id, + target=gitObject, + ) + return ref + @dataclass class GitObject(Node): @@ -347,17 +375,11 @@ def graphql(self, query: str, **kwargs: Any) -> Any: variable_values=kwargs, ) if r.errors: - # The GraphQL implementation loses all the stack traces!!! - # D: You can 'recover' them by deleting the - # 'except Exception as error' from GraphQL-core-next; need - # to file a bug report raise RuntimeError( "GraphQL query failed with errors:\n\n{}".format( "\n".join(str(e) for e in r.errors) ) ) - # The top-level object isn't indexable by strings, but - # everything underneath is, oddly enough return {"data": r.data} def push_hook(self, refNames: Sequence[str]) -> None: @@ -401,6 +423,36 @@ def _create_pull( "number": number, } + async def _create_pull_async( + self, owner: str, name: str, input: CreatePullRequestInput + ) -> CreatePullRequestPayload: + state = self.state + id = state.next_id() + repo = state.repository(owner, name) + number = state.next_pull_request_number(repo.id) + baseRef = None + headRef = None + if state.upstream_sh: + baseRef = await repo._make_ref_async(state, input["base"]) + headRef = await repo._make_ref_async(state, input["head"]) + pr = PullRequest( + id=id, + _repository=repo.id, + number=number, + closed=False, + url="https://github.com/{}/pull/{}".format(repo.nameWithOwner, number), + baseRef=baseRef, + baseRefName=input["base"], + headRef=headRef, + headRefName=input["head"], + title=input["title"], + body=input["body"], + ) + state.pull_requests[id] = pr + return { + "number": number, + } + # NB: This technically does have a payload, but we don't # use it so I didn't bother constructing it. def _update_pull( @@ -419,6 +471,20 @@ def _update_pull( if "body" in input and input["body"] is not None: pr.body = input["body"] + async def _update_pull_async( + self, owner: str, name: str, number: GitHubNumber, input: UpdatePullRequestInput + ) -> None: + state = self.state + repo = state.repository(owner, name) + pr = state.pull_request(repo, number) + if "title" in input and input["title"] is not None: + pr.title = input["title"] + if "base" in input and input["base"] is not None: + pr.baseRefName = input["base"] + pr.baseRef = await repo._make_ref_async(state, pr.baseRefName) + if "body" in input and input["body"] is not None: + pr.body = input["body"] + def _create_issue_comment( self, owner: str, name: str, comment_id: int, input: CreateIssueCommentInput ) -> CreateIssueCommentPayload: @@ -457,7 +523,22 @@ def _set_default_branch( repo = state.repository(owner, name) repo.defaultBranchRef = repo._make_ref(state, input["default_branch"]) + async def _set_default_branch_async( + self, owner: str, name: str, input: SetDefaultBranchInput + ) -> None: + state = self.state + repo = state.repository(owner, name) + repo.defaultBranchRef = await repo._make_ref_async( + state, input["default_branch"] + ) + def rest(self, method: str, path: str, **kwargs: Any) -> Any: + return self._rest_impl(method, path, **kwargs) + + async def arest(self, method: str, path: str, **kwargs: Any) -> Any: + return await self._arest_impl(method, path, **kwargs) + + def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: if method == "get": m = re.match(r"^repos/([^/]+)/([^/]+)/branches/([^/]+)/protection", path) if m: @@ -472,6 +553,12 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: "state": "closed" if pr.closed else "open", "title": pr.title, "body": pr.body, + "head": { + "ref": pr.headRefName, + }, + "base": { + "ref": pr.baseRefName, + }, } if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/comments/([^/]+)$", path): state = self.state @@ -536,3 +623,52 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: raise NotImplementedError( "FakeGitHubEndpoint REST {} {} not implemented".format(method.upper(), path) ) + + async def _arest_impl(self, method: str, path: str, **kwargs: Any) -> Any: + if method == "get": + return self._rest_impl(method, path, **kwargs) + + elif method == "post": + if m := re.match(r"^repos/([^/]+)/([^/]+)/pulls$", path): + return await self._create_pull_async( + m.group(1), m.group(2), cast(CreatePullRequestInput, kwargs) + ) + if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/comments", path): + return self._create_issue_comment( + m.group(1), + m.group(2), + GitHubNumber(int(m.group(3))), + cast(CreateIssueCommentInput, kwargs), + ) + if m := re.match( + r"^repos/([^/]+)/([^/]+)/pulls/([^/]+)/requested_reviewers", path + ): + return self._rest_impl(method, path, **kwargs) + if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/labels", path): + return self._rest_impl(method, path, **kwargs) + + elif method == "patch": + if m := re.match(r"^repos/([^/]+)/([^/]+)(?:/pulls/([^/]+))?$", path): + owner, name, number = m.groups() + if number is not None: + return await self._update_pull_async( + owner, + name, + GitHubNumber(int(number)), + cast(UpdatePullRequestInput, kwargs), + ) + elif "default_branch" in kwargs: + return await self._set_default_branch_async( + owner, name, cast(SetDefaultBranchInput, kwargs) + ) + if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/comments/([^/]+)$", path): + return self._update_issue_comment( + m.group(1), + m.group(2), + int(m.group(3)), + cast(UpdateIssueCommentInput, kwargs), + ) + + raise NotImplementedError( + "FakeGitHubEndpoint REST {} {} not implemented".format(method.upper(), path) + ) diff --git a/src/ghstack/github_real.py b/src/ghstack/github_real.py index 600fe64..d949df4 100644 --- a/src/ghstack/github_real.py +++ b/src/ghstack/github_real.py @@ -1,11 +1,14 @@ #!/usr/bin/env python3 +import asyncio import json import logging import re +import ssl import time from typing import Any, Dict, Optional, Sequence, Tuple, Union +import aiohttp import requests import ghstack.github @@ -120,12 +123,6 @@ def graphql(self, query: str, **kwargs: Any) -> Any: return r - def _proxies(self) -> Dict[str, str]: - if self.proxy: - return {"http": self.proxy, "https": self.proxy} - else: - return {} - def get_head_ref(self, **params: Any) -> str: if self.oauth_token: @@ -149,15 +146,40 @@ def get_head_ref(self, **params: Any) -> str: # couldn't find, fall back to regular query return super().get_head_ref(**params) - def rest(self, method: str, path: str, **kwargs: Any) -> Any: + def _proxies(self) -> Dict[str, str]: + if self.proxy: + return {"http": self.proxy, "https": self.proxy} + else: + return {} + + def _rest_headers(self) -> Dict[str, str]: assert self.oauth_token - headers = { + return { "Authorization": "token " + self.oauth_token, "Content-Type": "application/json", "User-Agent": "ghstack", "Accept": "application/vnd.github.v3+json", } + def _aiohttp_ssl(self) -> Any: + if self.verify is False: + return False + if self.verify is None and self.cert is None: + return None + + context = ssl.create_default_context( + cafile=self.verify if isinstance(self.verify, str) else None + ) + if isinstance(self.cert, tuple): + context.load_cert_chain(self.cert[0], self.cert[1]) + elif self.cert is not None: + context.load_cert_chain(self.cert) + return context + + def rest(self, method: str, path: str, **kwargs: Any) -> Any: + assert self.oauth_token + headers = self._rest_headers() + url = self.rest_endpoint.format(github_url=self.github_url) + "/" + path backoff_seconds = INITIAL_BACKOFF_SECONDS @@ -179,7 +201,7 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: try: r = resp.json() except ValueError: - logging.debug("Response body:\n{}".format(r.text)) + logging.debug("Response body:\n{}".format(resp.text)) raise else: pretty_json = json.dumps(r, indent=1) @@ -241,3 +263,98 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: return r raise RuntimeError("Exceeded maximum retries due to GitHub rate limiting") + + async def arest(self, method: str, path: str, **kwargs: Any) -> Any: + assert self.oauth_token + headers = self._rest_headers() + url = self.rest_endpoint.format(github_url=self.github_url) + "/" + path + + request_kwargs: Dict[str, Any] = { + "json": kwargs, + "headers": headers, + } + if self.proxy: + request_kwargs["proxy"] = self.proxy + aiohttp_ssl = self._aiohttp_ssl() + if aiohttp_ssl is not None: + request_kwargs["ssl"] = aiohttp_ssl + + backoff_seconds = INITIAL_BACKOFF_SECONDS + async with aiohttp.ClientSession() as session: + for attempt in range(0, MAX_RETRIES): + logging.debug("# {} {}".format(method, url)) + logging.debug("Request body:\n{}".format(json.dumps(kwargs, indent=1))) + + async with getattr(session, method)(url, **request_kwargs) as resp: + logging.debug("Response status: {}".format(resp.status)) + try: + r = await resp.json() + except (aiohttp.ContentTypeError, ValueError): + logging.debug("Response body:\n{}".format(await resp.text())) + raise + else: + pretty_json = json.dumps(r, indent=1) + logging.debug("Response JSON:\n{}".format(pretty_json)) + + if resp.status in (403, 429): + remaining_count = resp.headers.get("x-ratelimit-remaining") + reset_time = resp.headers.get("x-ratelimit-reset") + + if remaining_count == "0" and reset_time: + sleep_time = int(reset_time) - int(time.time()) + logging.warning( + f"Rate limit exceeded. Sleeping until reset in {sleep_time} seconds." + ) + await asyncio.sleep(sleep_time) + continue + else: + retry_after_seconds = resp.headers.get("retry-after") + if retry_after_seconds: + sleep_time = int(retry_after_seconds) + logging.warning( + f"Secondary rate limit hit. Sleeping for {sleep_time} seconds." + ) + else: + sleep_time = backoff_seconds + logging.warning( + f"Secondary rate limit hit. Sleeping for {sleep_time} seconds (exponential backoff)." + ) + backoff_seconds *= 2 + await asyncio.sleep(sleep_time) + continue + + if resp.status == 404: + raise ghstack.github.NotFoundError( + """\ +GitHub raised a 404 error on the request for +{url}. +Usually, this doesn't actually mean the page doesn't exist; instead, it +usually means that you didn't configure your OAuth token with enough +permissions. Please create a new OAuth token at +https://{github_url}/settings/tokens and DOUBLE CHECK that you checked +"public_repo" for permissions, and update ~/.ghstackrc with your new +value. + +Another possible reason for this error is if the repository has moved +to a new location or been renamed. Check that the repository URL is +still correct. +""".format( + url=url, github_url=self.github_url + ) + ) + + if resp.status >= 400: + raise RuntimeError(pretty_json) + + return r + + raise RuntimeError("Exceeded maximum retries due to GitHub rate limiting") + + async def aget(self, path: str, **kwargs: Any) -> Any: + return await self.arest("get", path, **kwargs) + + async def apost(self, path: str, **kwargs: Any) -> Any: + return await self.arest("post", path, **kwargs) + + async def apatch(self, path: str, **kwargs: Any) -> Any: + return await self.arest("patch", path, **kwargs) diff --git a/src/ghstack/shell.py b/src/ghstack/shell.py index 91d1f6a..681babd 100644 --- a/src/ghstack/shell.py +++ b/src/ghstack/shell.py @@ -197,8 +197,11 @@ async def run() -> Tuple[int, bytes, bytes]: assert proc.returncode is not None return (proc.returncode, out, err) - loop = asyncio.get_event_loop() - returncode, out, err = loop.run_until_complete(run()) + loop = asyncio.new_event_loop() + try: + returncode, out, err = loop.run_until_complete(run()) + finally: + loop.close() def decode(b: bytes) -> str: return ( @@ -327,7 +330,15 @@ def open(self, fn: str, mode: str) -> IO[Any]: fn: filename to open mode: mode to open the file as """ - return open(os.path.join(self.cwd, fn), mode) + return open(self.abspath(fn), mode) + + def abspath(self, fn: str) -> str: + """ + Resolve a path against this shell's current working directory. + """ + if os.path.isabs(fn): + return fn + return os.path.join(self.cwd, fn) def cd(self, d: str) -> None: """ From d74cb3f5cd428366f8e3e4db94dd6e2391afc6e2 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:04:07 -0400 Subject: [PATCH 2/7] Update [ghstack-poisoned] --- src/ghstack/github_fake.py | 6 +++--- src/ghstack/github_real.py | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/ghstack/github_fake.py b/src/ghstack/github_fake.py index e157445..8abeb5e 100644 --- a/src/ghstack/github_fake.py +++ b/src/ghstack/github_fake.py @@ -170,16 +170,16 @@ def __init__(self, upstream_sh: Optional[ghstack.shell.Shell]) -> None: # operations depend on repository state (e.g., what # the headRef is at the time a PR is created), so # we need this information - self.upstream_sh.git("init", "--bare", "-b", "master") + self.upstream_sh.git("init", "--bare", "-b", "main") tree = self.upstream_sh.git("write-tree") commit = self.upstream_sh.git("commit-tree", tree, input="Initial commit") - self.upstream_sh.git("branch", "-f", "master", commit) + self.upstream_sh.git("branch", "-f", "main", commit) # We only update this when a PATCH changes the default # branch; hopefully that's fine? In any case, it should # work for now since currently we only ever access the name # of the default branch rather than other parts of its ref. - repo.defaultBranchRef = repo._make_ref(self, "master") + repo.defaultBranchRef = repo._make_ref(self, "main") @dataclass diff --git a/src/ghstack/github_real.py b/src/ghstack/github_real.py index d949df4..b7d9bfc 100644 --- a/src/ghstack/github_real.py +++ b/src/ghstack/github_real.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import asyncio +import itertools import json import logging import re @@ -73,6 +74,7 @@ def __init__( self.github_url = github_url self.verify = verify self.cert = cert + self._rest_request_ids = itertools.count(1) def push_hook(self, refName: Sequence[str]) -> None: pass @@ -183,9 +185,13 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: url = self.rest_endpoint.format(github_url=self.github_url) + "/" + path backoff_seconds = INITIAL_BACKOFF_SECONDS + request_id = next(self._rest_request_ids) + log_prefix = f"rest[{request_id}]" for attempt in range(0, MAX_RETRIES): - logging.debug("# {} {}".format(method, url)) - logging.debug("Request body:\n{}".format(json.dumps(kwargs, indent=1))) + logging.debug("# %s %s %s", log_prefix, method, url) + logging.debug( + "%s request body:\n%s", log_prefix, json.dumps(kwargs, indent=1) + ) resp: requests.Response = getattr(requests, method)( url, @@ -196,16 +202,16 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: cert=self.cert, ) - logging.debug("Response status: {}".format(resp.status_code)) + logging.debug("%s response status: %s", log_prefix, resp.status_code) try: r = resp.json() except ValueError: - logging.debug("Response body:\n{}".format(resp.text)) + logging.debug("%s response body:\n%s", log_prefix, resp.text) raise else: pretty_json = json.dumps(r, indent=1) - logging.debug("Response JSON:\n{}".format(pretty_json)) + logging.debug("%s response JSON:\n%s", log_prefix, pretty_json) # Per Github rate limiting: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit if resp.status_code in (403, 429): @@ -280,21 +286,27 @@ async def arest(self, method: str, path: str, **kwargs: Any) -> Any: request_kwargs["ssl"] = aiohttp_ssl backoff_seconds = INITIAL_BACKOFF_SECONDS + request_id = next(self._rest_request_ids) + log_prefix = f"rest[{request_id}]" async with aiohttp.ClientSession() as session: for attempt in range(0, MAX_RETRIES): - logging.debug("# {} {}".format(method, url)) - logging.debug("Request body:\n{}".format(json.dumps(kwargs, indent=1))) + logging.debug("# %s %s %s", log_prefix, method, url) + logging.debug( + "%s request body:\n%s", log_prefix, json.dumps(kwargs, indent=1) + ) async with getattr(session, method)(url, **request_kwargs) as resp: - logging.debug("Response status: {}".format(resp.status)) + logging.debug("%s response status: %s", log_prefix, resp.status) try: r = await resp.json() except (aiohttp.ContentTypeError, ValueError): - logging.debug("Response body:\n{}".format(await resp.text())) + logging.debug( + "%s response body:\n%s", log_prefix, await resp.text() + ) raise else: pretty_json = json.dumps(r, indent=1) - logging.debug("Response JSON:\n{}".format(pretty_json)) + logging.debug("%s response JSON:\n%s", log_prefix, pretty_json) if resp.status in (403, 429): remaining_count = resp.headers.get("x-ratelimit-remaining") From 764f541edcae6d86bb6ed87b05dd99d15dd98423 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:08:32 -0400 Subject: [PATCH 3/7] Update [ghstack-poisoned] --- src/ghstack/github_fake.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ghstack/github_fake.py b/src/ghstack/github_fake.py index 8abeb5e..8ecd888 100644 --- a/src/ghstack/github_fake.py +++ b/src/ghstack/github_fake.py @@ -375,11 +375,17 @@ def graphql(self, query: str, **kwargs: Any) -> Any: variable_values=kwargs, ) if r.errors: + # The GraphQL implementation loses all the stack traces!!! + # D: You can 'recover' them by deleting the + # 'except Exception as error' from GraphQL-core-next; need + # to file a bug report raise RuntimeError( "GraphQL query failed with errors:\n\n{}".format( "\n".join(str(e) for e in r.errors) ) ) + # The top-level object isn't indexable by strings, but + # everything underneath is, oddly enough return {"data": r.data} def push_hook(self, refNames: Sequence[str]) -> None: From c80ecb9f1fe372b86f1147ab4d72c827597a3fb2 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:11:14 -0400 Subject: [PATCH 4/7] Update [ghstack-poisoned] --- src/ghstack/github.py | 8 +++- src/ghstack/github_fake.py | 88 ++---------------------------------- src/ghstack/github_real.py | 92 -------------------------------------- 3 files changed, 9 insertions(+), 179 deletions(-) diff --git a/src/ghstack/github.py b/src/ghstack/github.py index c135269..56d8a72 100644 --- a/src/ghstack/github.py +++ b/src/ghstack/github.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import asyncio from abc import ABCMeta, abstractmethod from typing import Any, Sequence @@ -82,7 +83,6 @@ def patch(self, path: str, **kwargs: Any) -> Any: """ return self.rest("patch", path, **kwargs) - @abstractmethod def rest(self, method: str, path: str, **kwargs: Any) -> Any: """ Send a 'method' request to endpoint 'path'. @@ -94,7 +94,11 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any: Returns: parsed JSON response """ - pass + loop = asyncio.new_event_loop() + try: + return loop.run_until_complete(self.arest(method, path, **kwargs)) + finally: + loop.close() @abstractmethod async def arest(self, method: str, path: str, **kwargs: Any) -> Any: diff --git a/src/ghstack/github_fake.py b/src/ghstack/github_fake.py index 8ecd888..b2008d5 100644 --- a/src/ghstack/github_fake.py +++ b/src/ghstack/github_fake.py @@ -170,16 +170,16 @@ def __init__(self, upstream_sh: Optional[ghstack.shell.Shell]) -> None: # operations depend on repository state (e.g., what # the headRef is at the time a PR is created), so # we need this information - self.upstream_sh.git("init", "--bare", "-b", "main") + self.upstream_sh.git("init", "--bare", "-b", "master") tree = self.upstream_sh.git("write-tree") commit = self.upstream_sh.git("commit-tree", tree, input="Initial commit") - self.upstream_sh.git("branch", "-f", "main", commit) + self.upstream_sh.git("branch", "-f", "master", commit) # We only update this when a PATCH changes the default # branch; hopefully that's fine? In any case, it should # work for now since currently we only ever access the name # of the default branch rather than other parts of its ref. - repo.defaultBranchRef = repo._make_ref(self, "main") + repo.defaultBranchRef = repo._make_ref(self, "master") @dataclass @@ -394,41 +394,6 @@ def push_hook(self, refNames: Sequence[str]) -> None: def notify_merged(self, pr_resolved: ghstack.diff.PullRequestResolved) -> None: self.state.notify_merged(pr_resolved) - def _create_pull( - self, owner: str, name: str, input: CreatePullRequestInput - ) -> CreatePullRequestPayload: - state = self.state - id = state.next_id() - repo = state.repository(owner, name) - number = state.next_pull_request_number(repo.id) - baseRef = None - headRef = None - # TODO: When we support forks, this needs rewriting to stop - # hard coded the repo we opened the pull request on - if state.upstream_sh: - baseRef = repo._make_ref(state, input["base"]) - headRef = repo._make_ref(state, input["head"]) - pr = PullRequest( - id=id, - _repository=repo.id, - number=number, - closed=False, - url="https://github.com/{}/pull/{}".format(repo.nameWithOwner, number), - baseRef=baseRef, - baseRefName=input["base"], - headRef=headRef, - headRefName=input["head"], - title=input["title"], - body=input["body"], - ) - # TODO: compute files changed - state.pull_requests[id] = pr - # This is only a subset of what the actual REST endpoint - # returns. - return { - "number": number, - } - async def _create_pull_async( self, owner: str, name: str, input: CreatePullRequestInput ) -> CreatePullRequestPayload: @@ -459,24 +424,6 @@ async def _create_pull_async( "number": number, } - # NB: This technically does have a payload, but we don't - # use it so I didn't bother constructing it. - def _update_pull( - self, owner: str, name: str, number: GitHubNumber, input: UpdatePullRequestInput - ) -> None: - state = self.state - repo = state.repository(owner, name) - pr = state.pull_request(repo, number) - # If I say input.get('title') is not None, mypy - # is unable to infer input['title'] is not None - if "title" in input and input["title"] is not None: - pr.title = input["title"] - if "base" in input and input["base"] is not None: - pr.baseRefName = input["base"] - pr.baseRef = repo._make_ref(state, pr.baseRefName) - if "body" in input and input["body"] is not None: - pr.body = input["body"] - async def _update_pull_async( self, owner: str, name: str, number: GitHubNumber, input: UpdatePullRequestInput ) -> None: @@ -520,15 +467,6 @@ def _update_issue_comment( if (r := input.get("body")) is not None: comment.body = r - # NB: This may have a payload, but we don't - # use it so I didn't bother constructing it. - def _set_default_branch( - self, owner: str, name: str, input: SetDefaultBranchInput - ) -> None: - state = self.state - repo = state.repository(owner, name) - repo.defaultBranchRef = repo._make_ref(state, input["default_branch"]) - async def _set_default_branch_async( self, owner: str, name: str, input: SetDefaultBranchInput ) -> None: @@ -538,9 +476,6 @@ async def _set_default_branch_async( state, input["default_branch"] ) - def rest(self, method: str, path: str, **kwargs: Any) -> Any: - return self._rest_impl(method, path, **kwargs) - async def arest(self, method: str, path: str, **kwargs: Any) -> Any: return await self._arest_impl(method, path, **kwargs) @@ -576,10 +511,6 @@ def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: } elif method == "post": - if m := re.match(r"^repos/([^/]+)/([^/]+)/pulls$", path): - return self._create_pull( - m.group(1), m.group(2), cast(CreatePullRequestInput, kwargs) - ) if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/comments", path): return self._create_issue_comment( m.group(1), @@ -606,19 +537,6 @@ def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: pr.labels.extend(labels) return {} elif method == "patch": - if m := re.match(r"^repos/([^/]+)/([^/]+)(?:/pulls/([^/]+))?$", path): - owner, name, number = m.groups() - if number is not None: - return self._update_pull( - owner, - name, - GitHubNumber(int(number)), - cast(UpdatePullRequestInput, kwargs), - ) - elif "default_branch" in kwargs: - return self._set_default_branch( - owner, name, cast(SetDefaultBranchInput, kwargs) - ) if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/comments/([^/]+)$", path): return self._update_issue_comment( m.group(1), diff --git a/src/ghstack/github_real.py b/src/ghstack/github_real.py index b7d9bfc..19108b8 100644 --- a/src/ghstack/github_real.py +++ b/src/ghstack/github_real.py @@ -178,98 +178,6 @@ def _aiohttp_ssl(self) -> Any: context.load_cert_chain(self.cert) return context - def rest(self, method: str, path: str, **kwargs: Any) -> Any: - assert self.oauth_token - headers = self._rest_headers() - - url = self.rest_endpoint.format(github_url=self.github_url) + "/" + path - - backoff_seconds = INITIAL_BACKOFF_SECONDS - request_id = next(self._rest_request_ids) - log_prefix = f"rest[{request_id}]" - for attempt in range(0, MAX_RETRIES): - logging.debug("# %s %s %s", log_prefix, method, url) - logging.debug( - "%s request body:\n%s", log_prefix, json.dumps(kwargs, indent=1) - ) - - resp: requests.Response = getattr(requests, method)( - url, - json=kwargs, - headers=headers, - proxies=self._proxies(), - verify=self.verify, - cert=self.cert, - ) - - logging.debug("%s response status: %s", log_prefix, resp.status_code) - - try: - r = resp.json() - except ValueError: - logging.debug("%s response body:\n%s", log_prefix, resp.text) - raise - else: - pretty_json = json.dumps(r, indent=1) - logging.debug("%s response JSON:\n%s", log_prefix, pretty_json) - - # Per Github rate limiting: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit - if resp.status_code in (403, 429): - remaining_count = resp.headers.get("x-ratelimit-remaining") - reset_time = resp.headers.get("x-ratelimit-reset") - - if remaining_count == "0" and reset_time: - sleep_time = int(reset_time) - int(time.time()) - logging.warning( - f"Rate limit exceeded. Sleeping until reset in {sleep_time} seconds." - ) - time.sleep(sleep_time) - continue - else: - retry_after_seconds = resp.headers.get("retry-after") - if retry_after_seconds: - sleep_time = int(retry_after_seconds) - logging.warning( - f"Secondary rate limit hit. Sleeping for {sleep_time} seconds." - ) - else: - sleep_time = backoff_seconds - logging.warning( - f"Secondary rate limit hit. Sleeping for {sleep_time} seconds (exponential backoff)." - ) - backoff_seconds *= 2 - time.sleep(sleep_time) - continue - - if resp.status_code == 404: - raise ghstack.github.NotFoundError( - """\ -GitHub raised a 404 error on the request for -{url}. -Usually, this doesn't actually mean the page doesn't exist; instead, it -usually means that you didn't configure your OAuth token with enough -permissions. Please create a new OAuth token at -https://{github_url}/settings/tokens and DOUBLE CHECK that you checked -"public_repo" for permissions, and update ~/.ghstackrc with your new -value. - -Another possible reason for this error is if the repository has moved -to a new location or been renamed. Check that the repository URL is -still correct. -""".format( - url=url, github_url=self.github_url - ) - ) - - try: - resp.raise_for_status() - except requests.HTTPError: - raise RuntimeError(pretty_json) - - return r - - raise RuntimeError("Exceeded maximum retries due to GitHub rate limiting") - async def arest(self, method: str, path: str, **kwargs: Any) -> Any: assert self.oauth_token headers = self._rest_headers() From f048d0dd45a726ba418e50ec4d4ff683629e843e Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:26:08 -0400 Subject: [PATCH 5/7] Update [ghstack-poisoned] --- test/checkout/basic.py.test | 6 ++-- test/checkout/same_base_allows.py.test | 2 +- test/checkout/same_base_rejects.py.test | 10 +++---- test/cherry_pick/basic.py.test | 8 +++--- test/cherry_pick/conflict.py.test | 6 ++-- test/cherry_pick/stack.py.test | 8 +++--- test/cherry_pick/stack_manual.py.test | 8 +++--- test/land/default_branch_change.py.test | 28 +++++++++---------- test/land/early_mod.py.test | 4 +-- test/land/ff.py.test | 2 +- test/land/ff_stack.py.test | 2 +- test/land/ff_stack_two_phase.py.test | 2 +- test/land/invalid_resubmit.py.test | 4 +-- test/land/non_ff.py.test | 4 +-- test/land/non_ff_stack_two_phase.py.test | 6 ++-- test/land/update_after_land.py.test | 6 ++-- test/log/explicit_pr.py.test | 2 +- test/submit/amend.py.test | 6 ++-- test/submit/amend_all.py.test | 6 ++-- test/submit/amend_bottom.py.test | 6 ++-- test/submit/amend_message_only.py.test | 6 ++-- test/submit/amend_top.py.test | 6 ++-- test/submit/bullet_divider.py.test | 6 ++-- test/submit/cherry_pick.py.test | 12 ++++---- test/submit/cli_reviewer_and_label.py.test | 6 ++-- test/submit/commit_amended_to_empty.py.test | 2 +- ...ot_revert_local_commit_msg_on_skip.py.test | 6 ++-- test/submit/empty_commit.py.test | 2 +- test/submit/minimal_fetch.py.test | 2 +- test/submit/multi.py.test | 6 ++-- test/submit/no_clobber.py.test | 12 ++++---- .../no_clobber_carriage_returns.py.test | 12 ++++---- test/submit/non_standard_base.py.test | 6 ++-- .../submit/preserve_downstream_closed.py.test | 2 +- .../submit/preserve_downstream_middle.py.test | 2 +- .../preserve_downstream_multiple.py.test | 2 +- .../preserve_downstream_new_on_top.py.test | 6 ++-- test/submit/preserve_downstream_prs.py.test | 2 +- .../preserve_downstream_rearrange.py.test | 2 +- test/submit/rebase.py.test | 12 ++++---- test/submit/remove_bottom_commit.py.test | 10 +++---- test/submit/reorder.py.test | 6 ++-- test/submit/reviewer_and_label.py.test | 6 ++-- test/submit/simple.py.test | 6 ++-- .../unrelated_malformed_gh_branch_ok.py.test | 8 +++--- test/submit/update_fields.py.test | 12 ++++---- ...lds_preserve_differential_revision.py.test | 12 ++++---- ...te_fields_preserves_commit_message.py.test | 6 ++-- test/unlink/basic.py.test | 8 +++--- 49 files changed, 156 insertions(+), 156 deletions(-) diff --git a/test/checkout/basic.py.test b/test/checkout/basic.py.test index e4e5cb4..06c5ab9 100644 --- a/test/checkout/basic.py.test +++ b/test/checkout/basic.py.test @@ -6,11 +6,11 @@ init_test() commit("A") (A,) = gh_submit("Initial commit") -# Move to master and create another commit -git("checkout", "master") +# Move to main and create another commit +git("checkout", "main") commit("B") -# Verify we're on master with commit B +# Verify we're on main with commit B current_log = git("log", "--oneline", "-n", "1") assert "Commit B" in current_log diff --git a/test/checkout/same_base_allows.py.test b/test/checkout/same_base_allows.py.test index ead555a..2f58ae8 100644 --- a/test/checkout/same_base_allows.py.test +++ b/test/checkout/same_base_allows.py.test @@ -12,7 +12,7 @@ assert len(diffs) == 2 A = diffs[0] # First commit (A) B = diffs[1] # Second commit (B) -# Both PRs should have the same merge-base with master (initial commit) +# Both PRs should have the same merge-base with main (initial commit) # Checkout PR A gh_checkout(f"https://github.com/pytorch/pytorch/pull/{A.number}") diff --git a/test/checkout/same_base_rejects.py.test b/test/checkout/same_base_rejects.py.test index 7c44c2d..6ee84ae 100644 --- a/test/checkout/same_base_rejects.py.test +++ b/test/checkout/same_base_rejects.py.test @@ -3,16 +3,16 @@ from ghstack.test_prelude import * init_test() -# Create first PR based on initial master +# Create first PR based on initial main commit("A") (A,) = gh_submit("First PR") -# Go back to master and advance it -git("checkout", "master") +# Go back to main and advance it +git("checkout", "main") commit("B") -git("push", "origin", "master") +git("push", "origin", "main") -# Create second PR based on new master (different merge-base) +# Create second PR based on new main (different merge-base) commit("C") (C,) = gh_submit("Second PR") diff --git a/test/cherry_pick/basic.py.test b/test/cherry_pick/basic.py.test index 1a115a8..26ef530 100644 --- a/test/cherry_pick/basic.py.test +++ b/test/cherry_pick/basic.py.test @@ -7,11 +7,11 @@ git("checkout", "-b", "feature") commit("A") (A,) = gh_submit("Initial commit") -# Switch to master and add another commit -git("checkout", "master") +# Switch to main and add another commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit A" should NOT be in recent master history +# Before cherry-pick, "Commit A" should NOT be in recent main history log_before = git("log", "--oneline", "-n", "2") assert "Commit A" not in log_before assert "Commit M" in log_before @@ -19,7 +19,7 @@ assert "Commit M" in log_before # Now cherry-pick the PR commit gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{A.number}") -# After cherry-pick, "Commit A" SHOULD be in recent master history +# After cherry-pick, "Commit A" SHOULD be in recent main history log_after = git("log", "--oneline", "-n", "3") assert "Commit A" in log_after assert "Commit M" in log_after diff --git a/test/cherry_pick/conflict.py.test b/test/cherry_pick/conflict.py.test index 3854a78..d983e4c 100644 --- a/test/cherry_pick/conflict.py.test +++ b/test/cherry_pick/conflict.py.test @@ -7,14 +7,14 @@ git("checkout", "-b", "feature") commit("A") (A,) = gh_submit("Initial commit") -# Switch to master and modify the same file differently -git("checkout", "master") +# Switch to main and modify the same file differently +git("checkout", "main") # The commit() function creates .txt with content "A" # Let's create a conflicting change by committing to the same file write_file_and_add("A.txt", "Different content") git("commit", "-m", "Conflicting change") -# Before cherry-pick, verify "Commit A" is not in master +# Before cherry-pick, verify "Commit A" is not in main log_before = git("log", "--oneline", "-n", "2") assert "Commit A" not in log_before assert "Conflicting change" in log_before diff --git a/test/cherry_pick/stack.py.test b/test/cherry_pick/stack.py.test index f701b57..e225b63 100644 --- a/test/cherry_pick/stack.py.test +++ b/test/cherry_pick/stack.py.test @@ -8,11 +8,11 @@ commit("A") commit("B") A, B = gh_submit("Initial stack") -# Switch to master and add another commit -git("checkout", "master") +# Switch to main and add another commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit B" should NOT be in recent master history +# Before cherry-pick, "Commit B" should NOT be in recent main history log_before = git("log", "--oneline", "-n", "2") assert "Commit B" not in log_before assert "Commit M" in log_before @@ -22,7 +22,7 @@ assert "Commit M" in log_before # in the test environment's temporary directories gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{B.number}") -# After cherry-pick, "Commit B" SHOULD be in recent master history +# After cherry-pick, "Commit B" SHOULD be in recent main history log_output = git("log", "--oneline", "-n", "3") assert "Commit B" in log_output assert "Commit M" in log_output diff --git a/test/cherry_pick/stack_manual.py.test b/test/cherry_pick/stack_manual.py.test index 0ae871d..aa13d5e 100644 --- a/test/cherry_pick/stack_manual.py.test +++ b/test/cherry_pick/stack_manual.py.test @@ -12,11 +12,11 @@ commit("C") # Create PRs for the stack A, B, C = gh_submit("Stack of 3 commits") -# Go back to master and create a divergent commit -git("checkout", "master") +# Go back to main and create a divergent commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit C" should NOT be in master history +# Before cherry-pick, "Commit C" should NOT be in main history log_before = git("log", "--oneline", "-n", "2") assert "Commit C" not in log_before assert "Commit M" in log_before @@ -24,7 +24,7 @@ assert "Commit M" in log_before # Now test cherry-picking the top commit only (not stack) gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{C.number}") -# After cherry-pick, should only have C and M in recent master history, not A and B +# After cherry-pick, should only have C and M in recent main history, not A and B log_output = git("log", "--oneline", "-n", "4") assert "Commit C" in log_output assert "Commit M" in log_output diff --git a/test/land/default_branch_change.py.test b/test/land/default_branch_change.py.test index 7160e23..51d36c4 100644 --- a/test/land/default_branch_change.py.test +++ b/test/land/default_branch_change.py.test @@ -6,14 +6,14 @@ commit("A") (diff1,) = gh_submit("Initial 1") assert diff1 is not None -# make main branch -git("branch", "main", "master") -git("push", "origin", "main") -# change default branch to main +# make release branch +git("branch", "release", "main") +git("push", "origin", "release") +# change default branch to release get_github().patch( "repos/pytorch/pytorch", name="pytorch", - default_branch="main", + default_branch="release", ) assert_github_state( @@ -33,7 +33,7 @@ assert_github_state( | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -42,11 +42,11 @@ assert_github_state( gh_land(diff1.pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """dc8bfe4 Initial commit""", ) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "main"), + get_upstream_sh().git("log", "--oneline", "release"), """\ 8927014 Commit A dc8bfe4 Initial commit""", @@ -57,11 +57,11 @@ commit("B") (diff2,) = gh_submit("Initial 2") assert diff2 is not None -# change default branch back to master +# change default branch back to main get_github().patch( "repos/pytorch/pytorch", name="pytorch", - default_branch="master", + default_branch="main", ) assert_github_state( @@ -90,13 +90,13 @@ assert_github_state( | Initial 2 * 742ae0b (gh/ezyang/2/base) | Initial 2 (base update) - * 8927014 (main, gh/ezyang/1/orig) + * 8927014 (release, gh/ezyang/1/orig) | Commit A | * 36fcfdf (gh/ezyang/1/head) | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -105,14 +105,14 @@ assert_github_state( gh_land(diff2.pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 6b7e56e Commit B (#501) 1132c50 Commit A (#500) dc8bfe4 Initial commit""", ) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "main"), + get_upstream_sh().git("log", "--oneline", "release"), """\ 8927014 Commit A dc8bfe4 Initial commit""", diff --git a/test/land/early_mod.py.test b/test/land/early_mod.py.test index 4d00b45..089f0e1 100644 --- a/test/land/early_mod.py.test +++ b/test/land/early_mod.py.test @@ -18,5 +18,5 @@ amend("A2") gh_submit("Update") gh_land(pr_url) -assert_expected_inline(get_upstream_sh().git("show", "master:A2.txt"), """A""") -assert_expected_inline(get_upstream_sh().git("show", "master:B.txt"), """A""") +assert_expected_inline(get_upstream_sh().git("show", "main:A2.txt"), """A""") +assert_expected_inline(get_upstream_sh().git("show", "main:B.txt"), """A""") diff --git a/test/land/ff.py.test b/test/land/ff.py.test index 6e30a9d..4c771b1 100644 --- a/test/land/ff.py.test +++ b/test/land/ff.py.test @@ -9,7 +9,7 @@ pr_url = diff.pr_url gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ d518c9f Commit A (#500) dc8bfe4 Initial commit""", diff --git a/test/land/ff_stack.py.test b/test/land/ff_stack.py.test index 5460c9f..e40f11e 100644 --- a/test/land/ff_stack.py.test +++ b/test/land/ff_stack.py.test @@ -14,7 +14,7 @@ pr_url = diff2.pr_url gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 4099517 Commit B (#501) c28edd5 Commit A (#500) diff --git a/test/land/ff_stack_two_phase.py.test b/test/land/ff_stack_two_phase.py.test index d73dff2..d2c0ca6 100644 --- a/test/land/ff_stack_two_phase.py.test +++ b/test/land/ff_stack_two_phase.py.test @@ -16,7 +16,7 @@ pr_url2 = diff2.pr_url gh_land(pr_url1) gh_land(pr_url2) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 4099517 Commit B (#501) c28edd5 Commit A (#500) diff --git a/test/land/invalid_resubmit.py.test b/test/land/invalid_resubmit.py.test index 1ee1657..af7a06c 100644 --- a/test/land/invalid_resubmit.py.test +++ b/test/land/invalid_resubmit.py.test @@ -20,7 +20,7 @@ assert_expected_raises_inline( # Do the remediation gh_unlink() -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("New PR") if is_direct(): @@ -52,7 +52,7 @@ else: | New PR * 5f392f5 (gh/ezyang/1/base) | New PR (base update) - * d518c9f (HEAD -> master) + * d518c9f (HEAD -> main) | Commit A (#500) * dc8bfe4 Initial commit diff --git a/test/land/non_ff.py.test b/test/land/non_ff.py.test index 7c9aab9..4493f4a 100644 --- a/test/land/non_ff.py.test +++ b/test/land/non_ff.py.test @@ -7,7 +7,7 @@ commit("A") assert diff is not None pr_url = diff.pr_url -git("reset", "--hard", "origin/master") +git("reset", "--hard", "origin/main") commit("U") git("push") @@ -15,7 +15,7 @@ git("checkout", "gh/ezyang/1/orig") gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 8b61aeb Commit A (#500) 38808c0 Commit U diff --git a/test/land/non_ff_stack_two_phase.py.test b/test/land/non_ff_stack_two_phase.py.test index ecc45a1..36e44dc 100644 --- a/test/land/non_ff_stack_two_phase.py.test +++ b/test/land/non_ff_stack_two_phase.py.test @@ -13,14 +13,14 @@ assert diff2 is not None pr_url1 = diff1.pr_url pr_url2 = diff2.pr_url -git("checkout", "origin/master") +git("checkout", "origin/main") commit("C") -git("push", "origin", "HEAD:master") +git("push", "origin", "HEAD:main") gh_land(pr_url1) gh_land(pr_url2) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 402e96c Commit B (#501) e388a10 Commit A (#500) diff --git a/test/land/update_after_land.py.test b/test/land/update_after_land.py.test index 88fa5c5..5e11c51 100644 --- a/test/land/update_after_land.py.test +++ b/test/land/update_after_land.py.test @@ -9,7 +9,7 @@ assert diff1 is not None assert diff2 is not None # setup an upstream commit, so the land isn't just trivial -git("reset", "--hard", "origin/master") +git("reset", "--hard", "origin/main") commit("U") git("push") @@ -30,7 +30,7 @@ assert_expected_raises_inline( ) # show the remediation works -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("Run 3") if is_direct(): @@ -64,7 +64,7 @@ else: |\\ Run 3 | * a800ca6 (gh/ezyang/2/base) | |\\ Run 3 (base update) - | | * 70eb094 (HEAD -> master) + | | * 70eb094 (HEAD -> main) | | | Commit A (#500) | | * 7f0288c | | | Commit U diff --git a/test/log/explicit_pr.py.test b/test/log/explicit_pr.py.test index ae9450a..b7e10dc 100644 --- a/test/log/explicit_pr.py.test +++ b/test/log/explicit_pr.py.test @@ -7,7 +7,7 @@ init_test() commit("A") (A,) = gh_submit("Initial commit") -git("checkout", "master") +git("checkout", "main") with captured_output() as (out, _): gh_log( diff --git a/test/submit/amend.py.test b/test/submit/amend.py.test index f30f147..87b359b 100644 --- a/test/submit/amend.py.test +++ b/test/submit/amend.py.test @@ -11,7 +11,7 @@ amend("A2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -24,7 +24,7 @@ if is_direct(): | Update A * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -49,7 +49,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_all.py.test b/test/submit/amend_all.py.test index 33ee96f..f37f8bc 100644 --- a/test/submit/amend_all.py.test +++ b/test/submit/amend_all.py.test @@ -17,7 +17,7 @@ A3, B3 = gh_submit("Update A") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): |/ Initial 2 * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -86,7 +86,7 @@ else: | |/ Initial 2 | * c05297f |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/amend_bottom.py.test b/test/submit/amend_bottom.py.test index fa99094..0e08154 100644 --- a/test/submit/amend_bottom.py.test +++ b/test/submit/amend_bottom.py.test @@ -17,7 +17,7 @@ A4, B4 = gh_submit("Update B") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): |/ Initial 2 * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -86,7 +86,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_message_only.py.test b/test/submit/amend_message_only.py.test index c909511..d7ab89b 100644 --- a/test/submit/amend_message_only.py.test +++ b/test/submit/amend_message_only.py.test @@ -12,7 +12,7 @@ git("commit", "--amend", "-m", A.commit_msg.replace("AAA", "BBB")) if is_direct(): assert_github_state( """\ - [O] #500 Commit AAA (gh/ezyang/1/head -> master) + [O] #500 Commit AAA (gh/ezyang/1/head -> main) This is commit AAA @@ -22,7 +22,7 @@ if is_direct(): * 5cd944b (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -44,7 +44,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_top.py.test b/test/submit/amend_top.py.test index d8c524a..1148d6a 100644 --- a/test/submit/amend_top.py.test +++ b/test/submit/amend_top.py.test @@ -14,7 +14,7 @@ A3, B3 = gh_submit("Update A") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -35,7 +35,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -75,7 +75,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/bullet_divider.py.test b/test/submit/bullet_divider.py.test index 14fcc2c..01dac4d 100644 --- a/test/submit/bullet_divider.py.test +++ b/test/submit/bullet_divider.py.test @@ -17,7 +17,7 @@ gh_submit("Initial") if is_direct(): assert_github_state( """\ - [O] #500 This is my commit (gh/ezyang/1/head -> master) + [O] #500 This is my commit (gh/ezyang/1/head -> main) * It starts with a fabulous * Bullet list @@ -28,7 +28,7 @@ if is_direct(): * b167219 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -53,7 +53,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/cherry_pick.py.test b/test/submit/cherry_pick.py.test index 950c878..5899455 100644 --- a/test/submit/cherry_pick.py.test +++ b/test/submit/cherry_pick.py.test @@ -8,9 +8,9 @@ commit("A") commit("B") A, B = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") cherry_pick(B) gh_submit("Cherry pick") @@ -18,13 +18,13 @@ gh_submit("Cherry pick") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A * 2193fd2 Initial 2 - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -36,7 +36,7 @@ if is_direct(): * 6d41420 (gh/ezyang/2/next, gh/ezyang/2/head) |\\ Cherry pick - | * 7ceeaa9 (HEAD -> master) + | * 7ceeaa9 (HEAD -> main) | | Commit M * | ce2fa9b | | Initial 2 @@ -76,7 +76,7 @@ else: |\\ Cherry pick | * 8f5c855 (gh/ezyang/2/base) | |\\ Cherry pick (base update) - | | * 7ceeaa9 (HEAD -> master) + | | * 7ceeaa9 (HEAD -> main) | | | Commit M * | | ca4399f |/ / Initial 2 diff --git a/test/submit/cli_reviewer_and_label.py.test b/test/submit/cli_reviewer_and_label.py.test index 117ba2b..2a4757d 100644 --- a/test/submit/cli_reviewer_and_label.py.test +++ b/test/submit/cli_reviewer_and_label.py.test @@ -23,7 +23,7 @@ assert_eq(get_pr_labels(501), ["enhancement", "priority-high"]) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): | Add B * 9cb2ede (gh/ezyang/1/next, gh/ezyang/1/head) | Initial commit - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -78,7 +78,7 @@ else: | | Initial commit | * 5956f18 (gh/ezyang/1/base) |/ Initial commit (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/commit_amended_to_empty.py.test b/test/submit/commit_amended_to_empty.py.test index b758608..06356bd 100644 --- a/test/submit/commit_amended_to_empty.py.test +++ b/test/submit/commit_amended_to_empty.py.test @@ -32,7 +32,7 @@ if not is_direct(): | Initial * ce88e73 (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/do_not_revert_local_commit_msg_on_skip.py.test b/test/submit/do_not_revert_local_commit_msg_on_skip.py.test index e0918a7..a292a8d 100644 --- a/test/submit/do_not_revert_local_commit_msg_on_skip.py.test +++ b/test/submit/do_not_revert_local_commit_msg_on_skip.py.test @@ -34,7 +34,7 @@ else: if is_direct(): assert_github_state( """\ - [O] #500 Commit TO_REPLACE (gh/ezyang/1/head -> master) + [O] #500 Commit TO_REPLACE (gh/ezyang/1/head -> main) This is commit TO_REPLACE @@ -44,7 +44,7 @@ if is_direct(): * 43ce90d (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -66,7 +66,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/empty_commit.py.test b/test/submit/empty_commit.py.test index 0b30b7b..8ce39d0 100644 --- a/test/submit/empty_commit.py.test +++ b/test/submit/empty_commit.py.test @@ -25,7 +25,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/minimal_fetch.py.test b/test/submit/minimal_fetch.py.test index 5c20a69..87cad92 100644 --- a/test/submit/minimal_fetch.py.test +++ b/test/submit/minimal_fetch.py.test @@ -6,7 +6,7 @@ init_test() git( "config", "remote.origin.fetch", - "+refs/heads/master:refs/remotes/origin/master", + "+refs/heads/main:refs/remotes/origin/main", ) commit("A") diff --git a/test/submit/multi.py.test b/test/submit/multi.py.test index 2152d1e..1cce0cc 100644 --- a/test/submit/multi.py.test +++ b/test/submit/multi.py.test @@ -7,7 +7,7 @@ A, B = gh_submit("Initial 1 and 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -25,7 +25,7 @@ if is_direct(): | Initial 1 and 2 * 6eac261 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 and 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) @@ -62,7 +62,7 @@ else: | | Initial 1 and 2 | * 954b129 (gh/ezyang/2/base) |/ Initial 1 and 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/no_clobber.py.test b/test/submit/no_clobber.py.test index c68ad71..735751d 100644 --- a/test/submit/no_clobber.py.test +++ b/test/submit/no_clobber.py.test @@ -23,7 +23,7 @@ Directly updated message body""", if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * **#500 Commit 1** @@ -36,7 +36,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -72,7 +72,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * __->__ #500 @@ -88,7 +88,7 @@ if is_direct(): | Update 1 * 6c1d876 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -113,7 +113,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/no_clobber_carriage_returns.py.test b/test/submit/no_clobber_carriage_returns.py.test index cda53f2..824c562 100644 --- a/test/submit/no_clobber_carriage_returns.py.test +++ b/test/submit/no_clobber_carriage_returns.py.test @@ -14,7 +14,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Commit 1 (gh/ezyang/1/head -> master) + [O] #500 Commit 1 (gh/ezyang/1/head -> main) Original message @@ -24,7 +24,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -46,7 +46,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -72,7 +72,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * #501 @@ -94,7 +94,7 @@ if is_direct(): | Initial 2 * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -131,7 +131,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/non_standard_base.py.test b/test/submit/non_standard_base.py.test index f78427b..a0f5820 100644 --- a/test/submit/non_standard_base.py.test +++ b/test/submit/non_standard_base.py.test @@ -3,12 +3,12 @@ from ghstack.test_prelude import * init_test() # make release branch -git("branch", "release", "master") +git("branch", "release", "main") # diverge release and regular branch -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") git("checkout", "release") commit("R") diff --git a/test/submit/preserve_downstream_closed.py.test b/test/submit/preserve_downstream_closed.py.test index 1c4d514..b96c6f0 100644 --- a/test/submit/preserve_downstream_closed.py.test +++ b/test/submit/preserve_downstream_closed.py.test @@ -60,7 +60,7 @@ else: | | Initial | * 8e6f9ba (gh/ezyang/2/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_middle.py.test b/test/submit/preserve_downstream_middle.py.test index 8bb20e6..173ade9 100644 --- a/test/submit/preserve_downstream_middle.py.test +++ b/test/submit/preserve_downstream_middle.py.test @@ -73,7 +73,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_multiple.py.test b/test/submit/preserve_downstream_multiple.py.test index 0851812..6472fb2 100644 --- a/test/submit/preserve_downstream_multiple.py.test +++ b/test/submit/preserve_downstream_multiple.py.test @@ -72,7 +72,7 @@ if not is_direct(): | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_new_on_top.py.test b/test/submit/preserve_downstream_new_on_top.py.test index cf0e9bf..63e4327 100644 --- a/test/submit/preserve_downstream_new_on_top.py.test +++ b/test/submit/preserve_downstream_new_on_top.py.test @@ -20,7 +20,7 @@ gh_submit("Add C", revs=["HEAD~", "HEAD"], stack=False) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -57,7 +57,7 @@ if is_direct(): | Initial * a6cb153 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -131,7 +131,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_prs.py.test b/test/submit/preserve_downstream_prs.py.test index eee0cd4..f1f2693 100644 --- a/test/submit/preserve_downstream_prs.py.test +++ b/test/submit/preserve_downstream_prs.py.test @@ -54,7 +54,7 @@ else: | | Initial | * 8e6f9ba (gh/ezyang/2/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_rearrange.py.test b/test/submit/preserve_downstream_rearrange.py.test index b8d0996..791622f 100644 --- a/test/submit/preserve_downstream_rearrange.py.test +++ b/test/submit/preserve_downstream_rearrange.py.test @@ -79,7 +79,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/rebase.py.test b/test/submit/rebase.py.test index 3d040d3..1bd001d 100644 --- a/test/submit/rebase.py.test +++ b/test/submit/rebase.py.test @@ -7,19 +7,19 @@ commit("A") commit("B") A2, B2 = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") git("checkout", "feature") -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("Rebase") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -39,7 +39,7 @@ if is_direct(): |\\ Rebase | * b0558d8 (gh/ezyang/1/next, gh/ezyang/1/head) | |\\ Rebase - | | * 7ceeaa9 (HEAD -> master) + | | * 7ceeaa9 (HEAD -> main) | | | Commit M * | | 0243aa2 |/ / Initial 2 @@ -90,7 +90,7 @@ else: | | | |\\ Rebase (base update) | | |_|/ | |/| | - | * | | 7ceeaa9 (HEAD -> master) + | * | | 7ceeaa9 (HEAD -> main) |/ / / Commit M | * / ca4399f | |/ Initial 2 diff --git a/test/submit/remove_bottom_commit.py.test b/test/submit/remove_bottom_commit.py.test index 331d3e8..fc13471 100644 --- a/test/submit/remove_bottom_commit.py.test +++ b/test/submit/remove_bottom_commit.py.test @@ -10,20 +10,20 @@ commit("A") commit("B") A, B = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") cherry_pick(B) (B2,) = gh_submit("Cherry pick") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A * 2193fd2 Initial 2 - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -39,7 +39,7 @@ if is_direct(): | Initial 2 * 2193fd2 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -81,7 +81,7 @@ else: | | Initial 2 | * f081adc (gh/ezyang/1/base) |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/reorder.py.test b/test/submit/reorder.py.test index c3b2a8b..7f8f123 100644 --- a/test/submit/reorder.py.test +++ b/test/submit/reorder.py.test @@ -20,7 +20,7 @@ if is_direct(): * f61b335 Reorder - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -38,7 +38,7 @@ if is_direct(): |/ Initial * 92a6dc7 | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -85,7 +85,7 @@ else: | |/ Initial | * 8e6f9ba |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/reviewer_and_label.py.test b/test/submit/reviewer_and_label.py.test index 57fe7f4..e49374a 100644 --- a/test/submit/reviewer_and_label.py.test +++ b/test/submit/reviewer_and_label.py.test @@ -14,7 +14,7 @@ assert_eq(get_pr_labels(500), ["bug", "enhancement"]) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -24,7 +24,7 @@ if is_direct(): * 9cb2ede (gh/ezyang/1/next, gh/ezyang/1/head) | Initial commit - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -46,7 +46,7 @@ else: | Initial commit * 5956f18 (gh/ezyang/1/base) | Initial commit (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/simple.py.test b/test/submit/simple.py.test index 636358b..83711b1 100644 --- a/test/submit/simple.py.test +++ b/test/submit/simple.py.test @@ -13,7 +13,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -31,7 +31,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -68,7 +68,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/unrelated_malformed_gh_branch_ok.py.test b/test/submit/unrelated_malformed_gh_branch_ok.py.test index 165a12c..0209a48 100644 --- a/test/submit/unrelated_malformed_gh_branch_ok.py.test +++ b/test/submit/unrelated_malformed_gh_branch_ok.py.test @@ -8,7 +8,7 @@ git("checkout", "-b", "gh/ezyang/malform") git("push", "origin", "gh/ezyang/malform") git("checkout", "-b", "gh/ezyang/non_int/head") git("push", "origin", "gh/ezyang/non_int/head") -git("checkout", "master") +git("checkout", "main") commit("A") (A,) = gh_submit("Initial 1") @@ -21,7 +21,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -39,7 +39,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master, gh/ezyang/non_int/head, gh/ezyang/malform) + * dc8bfe4 (HEAD -> main, gh/ezyang/non_int/head, gh/ezyang/malform) Initial commit """ ) @@ -76,7 +76,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master, gh/ezyang/non_int/head, gh/ezyang/malform) + * dc8bfe4 (HEAD -> main, gh/ezyang/non_int/head, gh/ezyang/malform) Initial commit """, ) diff --git a/test/submit/update_fields.py.test b/test/submit/update_fields.py.test index ea7ed55..b10de45 100644 --- a/test/submit/update_fields.py.test +++ b/test/submit/update_fields.py.test @@ -19,7 +19,7 @@ get_github().patch( if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Directly updated message body @@ -29,7 +29,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -48,7 +48,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ gh_submit("Update 1", update_fields=True) if is_direct(): assert_github_state( """\ - [O] #500 Commit 1 (gh/ezyang/1/head -> master) + [O] #500 Commit 1 (gh/ezyang/1/head -> main) Original message @@ -68,7 +68,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -90,7 +90,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/update_fields_preserve_differential_revision.py.test b/test/submit/update_fields_preserve_differential_revision.py.test index a06aa89..321bb72 100644 --- a/test/submit/update_fields_preserve_differential_revision.py.test +++ b/test/submit/update_fields_preserve_differential_revision.py.test @@ -19,7 +19,7 @@ get_github().patch( if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) @@ -34,7 +34,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -68,7 +68,7 @@ gh_submit("Update 1", update_fields=True) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -80,7 +80,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -104,7 +104,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/update_fields_preserves_commit_message.py.test b/test/submit/update_fields_preserves_commit_message.py.test index 84d0949..1300639 100644 --- a/test/submit/update_fields_preserves_commit_message.py.test +++ b/test/submit/update_fields_preserves_commit_message.py.test @@ -13,7 +13,7 @@ git("commit", "--amend", "-m", "Amended " + A.commit_msg) if is_direct(): assert_github_state( """\ - [O] #500 Amended Commit A (gh/ezyang/1/head -> master) + [O] #500 Amended Commit A (gh/ezyang/1/head -> main) This is commit A @@ -23,7 +23,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -45,7 +45,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/unlink/basic.py.test b/test/unlink/basic.py.test index 2484051..895273a 100644 --- a/test/unlink/basic.py.test +++ b/test/unlink/basic.py.test @@ -14,7 +14,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -26,7 +26,7 @@ if is_direct(): * 30b9f2a Initial 1 - [O] #502 Commit A (gh/ezyang/3/head -> master) + [O] #502 Commit A (gh/ezyang/3/head -> main) This is commit A @@ -54,7 +54,7 @@ if is_direct(): | | Initial 2 | * 2193fd2 (gh/ezyang/3/next, gh/ezyang/3/head) |/ Initial 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -119,7 +119,7 @@ else: | | Initial 2 | * c05297f (gh/ezyang/4/base) |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) From 68a19c799940f6636cc3706f58dda32243c00072 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:49:48 -0400 Subject: [PATCH 6/7] Update [ghstack-poisoned] --- test/checkout/basic.py.test | 6 ++-- test/checkout/same_base_allows.py.test | 2 +- test/checkout/same_base_rejects.py.test | 10 +++---- test/cherry_pick/basic.py.test | 8 +++--- test/cherry_pick/conflict.py.test | 6 ++-- test/cherry_pick/stack.py.test | 8 +++--- test/cherry_pick/stack_manual.py.test | 8 +++--- test/land/default_branch_change.py.test | 28 +++++++++---------- test/land/early_mod.py.test | 4 +-- test/land/ff.py.test | 2 +- test/land/ff_stack.py.test | 2 +- test/land/ff_stack_two_phase.py.test | 2 +- test/land/invalid_resubmit.py.test | 4 +-- test/land/non_ff.py.test | 4 +-- test/land/non_ff_stack_two_phase.py.test | 6 ++-- test/land/update_after_land.py.test | 6 ++-- test/log/explicit_pr.py.test | 2 +- test/submit/amend.py.test | 6 ++-- test/submit/amend_all.py.test | 6 ++-- test/submit/amend_bottom.py.test | 6 ++-- test/submit/amend_message_only.py.test | 6 ++-- test/submit/amend_top.py.test | 6 ++-- test/submit/bullet_divider.py.test | 6 ++-- test/submit/cherry_pick.py.test | 12 ++++---- test/submit/cli_reviewer_and_label.py.test | 6 ++-- test/submit/commit_amended_to_empty.py.test | 2 +- ...ot_revert_local_commit_msg_on_skip.py.test | 6 ++-- test/submit/empty_commit.py.test | 2 +- test/submit/minimal_fetch.py.test | 2 +- test/submit/multi.py.test | 6 ++-- test/submit/no_clobber.py.test | 12 ++++---- .../no_clobber_carriage_returns.py.test | 12 ++++---- test/submit/non_standard_base.py.test | 6 ++-- .../submit/preserve_downstream_closed.py.test | 2 +- .../submit/preserve_downstream_middle.py.test | 2 +- .../preserve_downstream_multiple.py.test | 2 +- .../preserve_downstream_new_on_top.py.test | 6 ++-- test/submit/preserve_downstream_prs.py.test | 2 +- .../preserve_downstream_rearrange.py.test | 2 +- test/submit/rebase.py.test | 12 ++++---- test/submit/remove_bottom_commit.py.test | 10 +++---- test/submit/reorder.py.test | 6 ++-- test/submit/reviewer_and_label.py.test | 6 ++-- test/submit/simple.py.test | 6 ++-- .../unrelated_malformed_gh_branch_ok.py.test | 8 +++--- test/submit/update_fields.py.test | 12 ++++---- ...lds_preserve_differential_revision.py.test | 12 ++++---- ...te_fields_preserves_commit_message.py.test | 6 ++-- test/unlink/basic.py.test | 8 +++--- 49 files changed, 156 insertions(+), 156 deletions(-) diff --git a/test/checkout/basic.py.test b/test/checkout/basic.py.test index e4e5cb4..06c5ab9 100644 --- a/test/checkout/basic.py.test +++ b/test/checkout/basic.py.test @@ -6,11 +6,11 @@ init_test() commit("A") (A,) = gh_submit("Initial commit") -# Move to master and create another commit -git("checkout", "master") +# Move to main and create another commit +git("checkout", "main") commit("B") -# Verify we're on master with commit B +# Verify we're on main with commit B current_log = git("log", "--oneline", "-n", "1") assert "Commit B" in current_log diff --git a/test/checkout/same_base_allows.py.test b/test/checkout/same_base_allows.py.test index ead555a..2f58ae8 100644 --- a/test/checkout/same_base_allows.py.test +++ b/test/checkout/same_base_allows.py.test @@ -12,7 +12,7 @@ assert len(diffs) == 2 A = diffs[0] # First commit (A) B = diffs[1] # Second commit (B) -# Both PRs should have the same merge-base with master (initial commit) +# Both PRs should have the same merge-base with main (initial commit) # Checkout PR A gh_checkout(f"https://github.com/pytorch/pytorch/pull/{A.number}") diff --git a/test/checkout/same_base_rejects.py.test b/test/checkout/same_base_rejects.py.test index 7c44c2d..6ee84ae 100644 --- a/test/checkout/same_base_rejects.py.test +++ b/test/checkout/same_base_rejects.py.test @@ -3,16 +3,16 @@ from ghstack.test_prelude import * init_test() -# Create first PR based on initial master +# Create first PR based on initial main commit("A") (A,) = gh_submit("First PR") -# Go back to master and advance it -git("checkout", "master") +# Go back to main and advance it +git("checkout", "main") commit("B") -git("push", "origin", "master") +git("push", "origin", "main") -# Create second PR based on new master (different merge-base) +# Create second PR based on new main (different merge-base) commit("C") (C,) = gh_submit("Second PR") diff --git a/test/cherry_pick/basic.py.test b/test/cherry_pick/basic.py.test index 1a115a8..26ef530 100644 --- a/test/cherry_pick/basic.py.test +++ b/test/cherry_pick/basic.py.test @@ -7,11 +7,11 @@ git("checkout", "-b", "feature") commit("A") (A,) = gh_submit("Initial commit") -# Switch to master and add another commit -git("checkout", "master") +# Switch to main and add another commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit A" should NOT be in recent master history +# Before cherry-pick, "Commit A" should NOT be in recent main history log_before = git("log", "--oneline", "-n", "2") assert "Commit A" not in log_before assert "Commit M" in log_before @@ -19,7 +19,7 @@ assert "Commit M" in log_before # Now cherry-pick the PR commit gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{A.number}") -# After cherry-pick, "Commit A" SHOULD be in recent master history +# After cherry-pick, "Commit A" SHOULD be in recent main history log_after = git("log", "--oneline", "-n", "3") assert "Commit A" in log_after assert "Commit M" in log_after diff --git a/test/cherry_pick/conflict.py.test b/test/cherry_pick/conflict.py.test index 3854a78..d983e4c 100644 --- a/test/cherry_pick/conflict.py.test +++ b/test/cherry_pick/conflict.py.test @@ -7,14 +7,14 @@ git("checkout", "-b", "feature") commit("A") (A,) = gh_submit("Initial commit") -# Switch to master and modify the same file differently -git("checkout", "master") +# Switch to main and modify the same file differently +git("checkout", "main") # The commit() function creates .txt with content "A" # Let's create a conflicting change by committing to the same file write_file_and_add("A.txt", "Different content") git("commit", "-m", "Conflicting change") -# Before cherry-pick, verify "Commit A" is not in master +# Before cherry-pick, verify "Commit A" is not in main log_before = git("log", "--oneline", "-n", "2") assert "Commit A" not in log_before assert "Conflicting change" in log_before diff --git a/test/cherry_pick/stack.py.test b/test/cherry_pick/stack.py.test index f701b57..e225b63 100644 --- a/test/cherry_pick/stack.py.test +++ b/test/cherry_pick/stack.py.test @@ -8,11 +8,11 @@ commit("A") commit("B") A, B = gh_submit("Initial stack") -# Switch to master and add another commit -git("checkout", "master") +# Switch to main and add another commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit B" should NOT be in recent master history +# Before cherry-pick, "Commit B" should NOT be in recent main history log_before = git("log", "--oneline", "-n", "2") assert "Commit B" not in log_before assert "Commit M" in log_before @@ -22,7 +22,7 @@ assert "Commit M" in log_before # in the test environment's temporary directories gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{B.number}") -# After cherry-pick, "Commit B" SHOULD be in recent master history +# After cherry-pick, "Commit B" SHOULD be in recent main history log_output = git("log", "--oneline", "-n", "3") assert "Commit B" in log_output assert "Commit M" in log_output diff --git a/test/cherry_pick/stack_manual.py.test b/test/cherry_pick/stack_manual.py.test index 0ae871d..aa13d5e 100644 --- a/test/cherry_pick/stack_manual.py.test +++ b/test/cherry_pick/stack_manual.py.test @@ -12,11 +12,11 @@ commit("C") # Create PRs for the stack A, B, C = gh_submit("Stack of 3 commits") -# Go back to master and create a divergent commit -git("checkout", "master") +# Go back to main and create a divergent commit +git("checkout", "main") commit("M") -# Before cherry-pick, "Commit C" should NOT be in master history +# Before cherry-pick, "Commit C" should NOT be in main history log_before = git("log", "--oneline", "-n", "2") assert "Commit C" not in log_before assert "Commit M" in log_before @@ -24,7 +24,7 @@ assert "Commit M" in log_before # Now test cherry-picking the top commit only (not stack) gh_cherry_pick(f"https://github.com/pytorch/pytorch/pull/{C.number}") -# After cherry-pick, should only have C and M in recent master history, not A and B +# After cherry-pick, should only have C and M in recent main history, not A and B log_output = git("log", "--oneline", "-n", "4") assert "Commit C" in log_output assert "Commit M" in log_output diff --git a/test/land/default_branch_change.py.test b/test/land/default_branch_change.py.test index 7160e23..51d36c4 100644 --- a/test/land/default_branch_change.py.test +++ b/test/land/default_branch_change.py.test @@ -6,14 +6,14 @@ commit("A") (diff1,) = gh_submit("Initial 1") assert diff1 is not None -# make main branch -git("branch", "main", "master") -git("push", "origin", "main") -# change default branch to main +# make release branch +git("branch", "release", "main") +git("push", "origin", "release") +# change default branch to release get_github().patch( "repos/pytorch/pytorch", name="pytorch", - default_branch="main", + default_branch="release", ) assert_github_state( @@ -33,7 +33,7 @@ assert_github_state( | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -42,11 +42,11 @@ assert_github_state( gh_land(diff1.pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """dc8bfe4 Initial commit""", ) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "main"), + get_upstream_sh().git("log", "--oneline", "release"), """\ 8927014 Commit A dc8bfe4 Initial commit""", @@ -57,11 +57,11 @@ commit("B") (diff2,) = gh_submit("Initial 2") assert diff2 is not None -# change default branch back to master +# change default branch back to main get_github().patch( "repos/pytorch/pytorch", name="pytorch", - default_branch="master", + default_branch="main", ) assert_github_state( @@ -90,13 +90,13 @@ assert_github_state( | Initial 2 * 742ae0b (gh/ezyang/2/base) | Initial 2 (base update) - * 8927014 (main, gh/ezyang/1/orig) + * 8927014 (release, gh/ezyang/1/orig) | Commit A | * 36fcfdf (gh/ezyang/1/head) | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -105,14 +105,14 @@ assert_github_state( gh_land(diff2.pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 6b7e56e Commit B (#501) 1132c50 Commit A (#500) dc8bfe4 Initial commit""", ) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "main"), + get_upstream_sh().git("log", "--oneline", "release"), """\ 8927014 Commit A dc8bfe4 Initial commit""", diff --git a/test/land/early_mod.py.test b/test/land/early_mod.py.test index 4d00b45..089f0e1 100644 --- a/test/land/early_mod.py.test +++ b/test/land/early_mod.py.test @@ -18,5 +18,5 @@ amend("A2") gh_submit("Update") gh_land(pr_url) -assert_expected_inline(get_upstream_sh().git("show", "master:A2.txt"), """A""") -assert_expected_inline(get_upstream_sh().git("show", "master:B.txt"), """A""") +assert_expected_inline(get_upstream_sh().git("show", "main:A2.txt"), """A""") +assert_expected_inline(get_upstream_sh().git("show", "main:B.txt"), """A""") diff --git a/test/land/ff.py.test b/test/land/ff.py.test index 6e30a9d..4c771b1 100644 --- a/test/land/ff.py.test +++ b/test/land/ff.py.test @@ -9,7 +9,7 @@ pr_url = diff.pr_url gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ d518c9f Commit A (#500) dc8bfe4 Initial commit""", diff --git a/test/land/ff_stack.py.test b/test/land/ff_stack.py.test index 5460c9f..e40f11e 100644 --- a/test/land/ff_stack.py.test +++ b/test/land/ff_stack.py.test @@ -14,7 +14,7 @@ pr_url = diff2.pr_url gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 4099517 Commit B (#501) c28edd5 Commit A (#500) diff --git a/test/land/ff_stack_two_phase.py.test b/test/land/ff_stack_two_phase.py.test index d73dff2..d2c0ca6 100644 --- a/test/land/ff_stack_two_phase.py.test +++ b/test/land/ff_stack_two_phase.py.test @@ -16,7 +16,7 @@ pr_url2 = diff2.pr_url gh_land(pr_url1) gh_land(pr_url2) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 4099517 Commit B (#501) c28edd5 Commit A (#500) diff --git a/test/land/invalid_resubmit.py.test b/test/land/invalid_resubmit.py.test index 1ee1657..af7a06c 100644 --- a/test/land/invalid_resubmit.py.test +++ b/test/land/invalid_resubmit.py.test @@ -20,7 +20,7 @@ assert_expected_raises_inline( # Do the remediation gh_unlink() -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("New PR") if is_direct(): @@ -52,7 +52,7 @@ else: | New PR * 5f392f5 (gh/ezyang/1/base) | New PR (base update) - * d518c9f (HEAD -> master) + * d518c9f (HEAD -> main) | Commit A (#500) * dc8bfe4 Initial commit diff --git a/test/land/non_ff.py.test b/test/land/non_ff.py.test index 7c9aab9..4493f4a 100644 --- a/test/land/non_ff.py.test +++ b/test/land/non_ff.py.test @@ -7,7 +7,7 @@ commit("A") assert diff is not None pr_url = diff.pr_url -git("reset", "--hard", "origin/master") +git("reset", "--hard", "origin/main") commit("U") git("push") @@ -15,7 +15,7 @@ git("checkout", "gh/ezyang/1/orig") gh_land(pr_url) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 8b61aeb Commit A (#500) 38808c0 Commit U diff --git a/test/land/non_ff_stack_two_phase.py.test b/test/land/non_ff_stack_two_phase.py.test index ecc45a1..36e44dc 100644 --- a/test/land/non_ff_stack_two_phase.py.test +++ b/test/land/non_ff_stack_two_phase.py.test @@ -13,14 +13,14 @@ assert diff2 is not None pr_url1 = diff1.pr_url pr_url2 = diff2.pr_url -git("checkout", "origin/master") +git("checkout", "origin/main") commit("C") -git("push", "origin", "HEAD:master") +git("push", "origin", "HEAD:main") gh_land(pr_url1) gh_land(pr_url2) assert_expected_inline( - get_upstream_sh().git("log", "--oneline", "master"), + get_upstream_sh().git("log", "--oneline", "main"), """\ 402e96c Commit B (#501) e388a10 Commit A (#500) diff --git a/test/land/update_after_land.py.test b/test/land/update_after_land.py.test index 88fa5c5..5e11c51 100644 --- a/test/land/update_after_land.py.test +++ b/test/land/update_after_land.py.test @@ -9,7 +9,7 @@ assert diff1 is not None assert diff2 is not None # setup an upstream commit, so the land isn't just trivial -git("reset", "--hard", "origin/master") +git("reset", "--hard", "origin/main") commit("U") git("push") @@ -30,7 +30,7 @@ assert_expected_raises_inline( ) # show the remediation works -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("Run 3") if is_direct(): @@ -64,7 +64,7 @@ else: |\\ Run 3 | * a800ca6 (gh/ezyang/2/base) | |\\ Run 3 (base update) - | | * 70eb094 (HEAD -> master) + | | * 70eb094 (HEAD -> main) | | | Commit A (#500) | | * 7f0288c | | | Commit U diff --git a/test/log/explicit_pr.py.test b/test/log/explicit_pr.py.test index ae9450a..b7e10dc 100644 --- a/test/log/explicit_pr.py.test +++ b/test/log/explicit_pr.py.test @@ -7,7 +7,7 @@ init_test() commit("A") (A,) = gh_submit("Initial commit") -git("checkout", "master") +git("checkout", "main") with captured_output() as (out, _): gh_log( diff --git a/test/submit/amend.py.test b/test/submit/amend.py.test index f30f147..87b359b 100644 --- a/test/submit/amend.py.test +++ b/test/submit/amend.py.test @@ -11,7 +11,7 @@ amend("A2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -24,7 +24,7 @@ if is_direct(): | Update A * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -49,7 +49,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_all.py.test b/test/submit/amend_all.py.test index 33ee96f..f37f8bc 100644 --- a/test/submit/amend_all.py.test +++ b/test/submit/amend_all.py.test @@ -17,7 +17,7 @@ A3, B3 = gh_submit("Update A") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): |/ Initial 2 * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -86,7 +86,7 @@ else: | |/ Initial 2 | * c05297f |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/amend_bottom.py.test b/test/submit/amend_bottom.py.test index fa99094..0e08154 100644 --- a/test/submit/amend_bottom.py.test +++ b/test/submit/amend_bottom.py.test @@ -17,7 +17,7 @@ A4, B4 = gh_submit("Update B") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): |/ Initial 2 * 8c7d059 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -86,7 +86,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_message_only.py.test b/test/submit/amend_message_only.py.test index c909511..d7ab89b 100644 --- a/test/submit/amend_message_only.py.test +++ b/test/submit/amend_message_only.py.test @@ -12,7 +12,7 @@ git("commit", "--amend", "-m", A.commit_msg.replace("AAA", "BBB")) if is_direct(): assert_github_state( """\ - [O] #500 Commit AAA (gh/ezyang/1/head -> master) + [O] #500 Commit AAA (gh/ezyang/1/head -> main) This is commit AAA @@ -22,7 +22,7 @@ if is_direct(): * 5cd944b (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -44,7 +44,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/amend_top.py.test b/test/submit/amend_top.py.test index d8c524a..1148d6a 100644 --- a/test/submit/amend_top.py.test +++ b/test/submit/amend_top.py.test @@ -14,7 +14,7 @@ A3, B3 = gh_submit("Update A") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -35,7 +35,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -75,7 +75,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/bullet_divider.py.test b/test/submit/bullet_divider.py.test index 14fcc2c..01dac4d 100644 --- a/test/submit/bullet_divider.py.test +++ b/test/submit/bullet_divider.py.test @@ -17,7 +17,7 @@ gh_submit("Initial") if is_direct(): assert_github_state( """\ - [O] #500 This is my commit (gh/ezyang/1/head -> master) + [O] #500 This is my commit (gh/ezyang/1/head -> main) * It starts with a fabulous * Bullet list @@ -28,7 +28,7 @@ if is_direct(): * b167219 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -53,7 +53,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/cherry_pick.py.test b/test/submit/cherry_pick.py.test index 950c878..5899455 100644 --- a/test/submit/cherry_pick.py.test +++ b/test/submit/cherry_pick.py.test @@ -8,9 +8,9 @@ commit("A") commit("B") A, B = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") cherry_pick(B) gh_submit("Cherry pick") @@ -18,13 +18,13 @@ gh_submit("Cherry pick") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A * 2193fd2 Initial 2 - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -36,7 +36,7 @@ if is_direct(): * 6d41420 (gh/ezyang/2/next, gh/ezyang/2/head) |\\ Cherry pick - | * 7ceeaa9 (HEAD -> master) + | * 7ceeaa9 (HEAD -> main) | | Commit M * | ce2fa9b | | Initial 2 @@ -76,7 +76,7 @@ else: |\\ Cherry pick | * 8f5c855 (gh/ezyang/2/base) | |\\ Cherry pick (base update) - | | * 7ceeaa9 (HEAD -> master) + | | * 7ceeaa9 (HEAD -> main) | | | Commit M * | | ca4399f |/ / Initial 2 diff --git a/test/submit/cli_reviewer_and_label.py.test b/test/submit/cli_reviewer_and_label.py.test index 117ba2b..2a4757d 100644 --- a/test/submit/cli_reviewer_and_label.py.test +++ b/test/submit/cli_reviewer_and_label.py.test @@ -23,7 +23,7 @@ assert_eq(get_pr_labels(501), ["enhancement", "priority-high"]) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -41,7 +41,7 @@ if is_direct(): | Add B * 9cb2ede (gh/ezyang/1/next, gh/ezyang/1/head) | Initial commit - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -78,7 +78,7 @@ else: | | Initial commit | * 5956f18 (gh/ezyang/1/base) |/ Initial commit (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/commit_amended_to_empty.py.test b/test/submit/commit_amended_to_empty.py.test index b758608..06356bd 100644 --- a/test/submit/commit_amended_to_empty.py.test +++ b/test/submit/commit_amended_to_empty.py.test @@ -32,7 +32,7 @@ if not is_direct(): | Initial * ce88e73 (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/do_not_revert_local_commit_msg_on_skip.py.test b/test/submit/do_not_revert_local_commit_msg_on_skip.py.test index e0918a7..a292a8d 100644 --- a/test/submit/do_not_revert_local_commit_msg_on_skip.py.test +++ b/test/submit/do_not_revert_local_commit_msg_on_skip.py.test @@ -34,7 +34,7 @@ else: if is_direct(): assert_github_state( """\ - [O] #500 Commit TO_REPLACE (gh/ezyang/1/head -> master) + [O] #500 Commit TO_REPLACE (gh/ezyang/1/head -> main) This is commit TO_REPLACE @@ -44,7 +44,7 @@ if is_direct(): * 43ce90d (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -66,7 +66,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/empty_commit.py.test b/test/submit/empty_commit.py.test index 0b30b7b..8ce39d0 100644 --- a/test/submit/empty_commit.py.test +++ b/test/submit/empty_commit.py.test @@ -25,7 +25,7 @@ else: | Initial * 11e6d4d (gh/ezyang/1/base) | Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/minimal_fetch.py.test b/test/submit/minimal_fetch.py.test index 5c20a69..87cad92 100644 --- a/test/submit/minimal_fetch.py.test +++ b/test/submit/minimal_fetch.py.test @@ -6,7 +6,7 @@ init_test() git( "config", "remote.origin.fetch", - "+refs/heads/master:refs/remotes/origin/master", + "+refs/heads/main:refs/remotes/origin/main", ) commit("A") diff --git a/test/submit/multi.py.test b/test/submit/multi.py.test index 2152d1e..1cce0cc 100644 --- a/test/submit/multi.py.test +++ b/test/submit/multi.py.test @@ -7,7 +7,7 @@ A, B = gh_submit("Initial 1 and 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -25,7 +25,7 @@ if is_direct(): | Initial 1 and 2 * 6eac261 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 and 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) @@ -62,7 +62,7 @@ else: | | Initial 1 and 2 | * 954b129 (gh/ezyang/2/base) |/ Initial 1 and 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/no_clobber.py.test b/test/submit/no_clobber.py.test index c68ad71..735751d 100644 --- a/test/submit/no_clobber.py.test +++ b/test/submit/no_clobber.py.test @@ -23,7 +23,7 @@ Directly updated message body""", if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * **#500 Commit 1** @@ -36,7 +36,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -72,7 +72,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * __->__ #500 @@ -88,7 +88,7 @@ if is_direct(): | Update 1 * 6c1d876 | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -113,7 +113,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/no_clobber_carriage_returns.py.test b/test/submit/no_clobber_carriage_returns.py.test index cda53f2..824c562 100644 --- a/test/submit/no_clobber_carriage_returns.py.test +++ b/test/submit/no_clobber_carriage_returns.py.test @@ -14,7 +14,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Commit 1 (gh/ezyang/1/head -> master) + [O] #500 Commit 1 (gh/ezyang/1/head -> main) Original message @@ -24,7 +24,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -46,7 +46,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -72,7 +72,7 @@ tick() if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Stack: * #501 @@ -94,7 +94,7 @@ if is_direct(): | Initial 2 * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -131,7 +131,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/non_standard_base.py.test b/test/submit/non_standard_base.py.test index f78427b..a0f5820 100644 --- a/test/submit/non_standard_base.py.test +++ b/test/submit/non_standard_base.py.test @@ -3,12 +3,12 @@ from ghstack.test_prelude import * init_test() # make release branch -git("branch", "release", "master") +git("branch", "release", "main") # diverge release and regular branch -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") git("checkout", "release") commit("R") diff --git a/test/submit/preserve_downstream_closed.py.test b/test/submit/preserve_downstream_closed.py.test index 1c4d514..b96c6f0 100644 --- a/test/submit/preserve_downstream_closed.py.test +++ b/test/submit/preserve_downstream_closed.py.test @@ -60,7 +60,7 @@ else: | | Initial | * 8e6f9ba (gh/ezyang/2/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_middle.py.test b/test/submit/preserve_downstream_middle.py.test index 8bb20e6..173ade9 100644 --- a/test/submit/preserve_downstream_middle.py.test +++ b/test/submit/preserve_downstream_middle.py.test @@ -73,7 +73,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_multiple.py.test b/test/submit/preserve_downstream_multiple.py.test index 0851812..6472fb2 100644 --- a/test/submit/preserve_downstream_multiple.py.test +++ b/test/submit/preserve_downstream_multiple.py.test @@ -72,7 +72,7 @@ if not is_direct(): | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_new_on_top.py.test b/test/submit/preserve_downstream_new_on_top.py.test index cf0e9bf..63e4327 100644 --- a/test/submit/preserve_downstream_new_on_top.py.test +++ b/test/submit/preserve_downstream_new_on_top.py.test @@ -20,7 +20,7 @@ gh_submit("Add C", revs=["HEAD~", "HEAD"], stack=False) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -57,7 +57,7 @@ if is_direct(): | Initial * a6cb153 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -131,7 +131,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_prs.py.test b/test/submit/preserve_downstream_prs.py.test index eee0cd4..f1f2693 100644 --- a/test/submit/preserve_downstream_prs.py.test +++ b/test/submit/preserve_downstream_prs.py.test @@ -54,7 +54,7 @@ else: | | Initial | * 8e6f9ba (gh/ezyang/2/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/preserve_downstream_rearrange.py.test b/test/submit/preserve_downstream_rearrange.py.test index b8d0996..791622f 100644 --- a/test/submit/preserve_downstream_rearrange.py.test +++ b/test/submit/preserve_downstream_rearrange.py.test @@ -79,7 +79,7 @@ else: | | Initial | * 8fe2454 (gh/ezyang/3/base) |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/rebase.py.test b/test/submit/rebase.py.test index 3d040d3..1bd001d 100644 --- a/test/submit/rebase.py.test +++ b/test/submit/rebase.py.test @@ -7,19 +7,19 @@ commit("A") commit("B") A2, B2 = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") commit("M") -git("push", "origin", "master") +git("push", "origin", "main") git("checkout", "feature") -git("rebase", "origin/master") +git("rebase", "origin/main") gh_submit("Rebase") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -39,7 +39,7 @@ if is_direct(): |\\ Rebase | * b0558d8 (gh/ezyang/1/next, gh/ezyang/1/head) | |\\ Rebase - | | * 7ceeaa9 (HEAD -> master) + | | * 7ceeaa9 (HEAD -> main) | | | Commit M * | | 0243aa2 |/ / Initial 2 @@ -90,7 +90,7 @@ else: | | | |\\ Rebase (base update) | | |_|/ | |/| | - | * | | 7ceeaa9 (HEAD -> master) + | * | | 7ceeaa9 (HEAD -> main) |/ / / Commit M | * / ca4399f | |/ Initial 2 diff --git a/test/submit/remove_bottom_commit.py.test b/test/submit/remove_bottom_commit.py.test index 331d3e8..fc13471 100644 --- a/test/submit/remove_bottom_commit.py.test +++ b/test/submit/remove_bottom_commit.py.test @@ -10,20 +10,20 @@ commit("A") commit("B") A, B = gh_submit("Initial 2") -git("checkout", "master") +git("checkout", "main") cherry_pick(B) (B2,) = gh_submit("Cherry pick") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A * 2193fd2 Initial 2 - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -39,7 +39,7 @@ if is_direct(): | Initial 2 * 2193fd2 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -81,7 +81,7 @@ else: | | Initial 2 | * f081adc (gh/ezyang/1/base) |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/reorder.py.test b/test/submit/reorder.py.test index c3b2a8b..7f8f123 100644 --- a/test/submit/reorder.py.test +++ b/test/submit/reorder.py.test @@ -20,7 +20,7 @@ if is_direct(): * f61b335 Reorder - [O] #501 Commit B (gh/ezyang/2/head -> master) + [O] #501 Commit B (gh/ezyang/2/head -> main) This is commit B @@ -38,7 +38,7 @@ if is_direct(): |/ Initial * 92a6dc7 | Initial - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -85,7 +85,7 @@ else: | |/ Initial | * 8e6f9ba |/ Initial (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/reviewer_and_label.py.test b/test/submit/reviewer_and_label.py.test index 57fe7f4..e49374a 100644 --- a/test/submit/reviewer_and_label.py.test +++ b/test/submit/reviewer_and_label.py.test @@ -14,7 +14,7 @@ assert_eq(get_pr_labels(500), ["bug", "enhancement"]) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -24,7 +24,7 @@ if is_direct(): * 9cb2ede (gh/ezyang/1/next, gh/ezyang/1/head) | Initial commit - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -46,7 +46,7 @@ else: | Initial commit * 5956f18 (gh/ezyang/1/base) | Initial commit (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/simple.py.test b/test/submit/simple.py.test index 636358b..83711b1 100644 --- a/test/submit/simple.py.test +++ b/test/submit/simple.py.test @@ -13,7 +13,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -31,7 +31,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -68,7 +68,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """, ) diff --git a/test/submit/unrelated_malformed_gh_branch_ok.py.test b/test/submit/unrelated_malformed_gh_branch_ok.py.test index 165a12c..0209a48 100644 --- a/test/submit/unrelated_malformed_gh_branch_ok.py.test +++ b/test/submit/unrelated_malformed_gh_branch_ok.py.test @@ -8,7 +8,7 @@ git("checkout", "-b", "gh/ezyang/malform") git("push", "origin", "gh/ezyang/malform") git("checkout", "-b", "gh/ezyang/non_int/head") git("push", "origin", "gh/ezyang/non_int/head") -git("checkout", "master") +git("checkout", "main") commit("A") (A,) = gh_submit("Initial 1") @@ -21,7 +21,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -39,7 +39,7 @@ if is_direct(): | Initial 2 * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master, gh/ezyang/non_int/head, gh/ezyang/malform) + * dc8bfe4 (HEAD -> main, gh/ezyang/non_int/head, gh/ezyang/malform) Initial commit """ ) @@ -76,7 +76,7 @@ else: | | Initial 1 | * 5a32949 (gh/ezyang/1/base) |/ Initial 1 (base update) - * dc8bfe4 (HEAD -> master, gh/ezyang/non_int/head, gh/ezyang/malform) + * dc8bfe4 (HEAD -> main, gh/ezyang/non_int/head, gh/ezyang/malform) Initial commit """, ) diff --git a/test/submit/update_fields.py.test b/test/submit/update_fields.py.test index ea7ed55..b10de45 100644 --- a/test/submit/update_fields.py.test +++ b/test/submit/update_fields.py.test @@ -19,7 +19,7 @@ get_github().patch( if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) Directly updated message body @@ -29,7 +29,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -48,7 +48,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ gh_submit("Update 1", update_fields=True) if is_direct(): assert_github_state( """\ - [O] #500 Commit 1 (gh/ezyang/1/head -> master) + [O] #500 Commit 1 (gh/ezyang/1/head -> main) Original message @@ -68,7 +68,7 @@ if is_direct(): * 6c1d876 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -90,7 +90,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/update_fields_preserve_differential_revision.py.test b/test/submit/update_fields_preserve_differential_revision.py.test index a06aa89..321bb72 100644 --- a/test/submit/update_fields_preserve_differential_revision.py.test +++ b/test/submit/update_fields_preserve_differential_revision.py.test @@ -19,7 +19,7 @@ get_github().patch( if is_direct(): assert_github_state( """\ - [O] #500 Directly updated title (gh/ezyang/1/head -> master) + [O] #500 Directly updated title (gh/ezyang/1/head -> main) @@ -34,7 +34,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -58,7 +58,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -68,7 +68,7 @@ gh_submit("Update 1", update_fields=True) if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -80,7 +80,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -104,7 +104,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/submit/update_fields_preserves_commit_message.py.test b/test/submit/update_fields_preserves_commit_message.py.test index 84d0949..1300639 100644 --- a/test/submit/update_fields_preserves_commit_message.py.test +++ b/test/submit/update_fields_preserves_commit_message.py.test @@ -13,7 +13,7 @@ git("commit", "--amend", "-m", "Amended " + A.commit_msg) if is_direct(): assert_github_state( """\ - [O] #500 Amended Commit A (gh/ezyang/1/head -> master) + [O] #500 Amended Commit A (gh/ezyang/1/head -> main) This is commit A @@ -23,7 +23,7 @@ if is_direct(): * 8c7d059 (gh/ezyang/1/next, gh/ezyang/1/head) | Initial 1 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -45,7 +45,7 @@ else: | Initial 1 * 5a32949 (gh/ezyang/1/base) | Initial 1 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) diff --git a/test/unlink/basic.py.test b/test/unlink/basic.py.test index 2484051..895273a 100644 --- a/test/unlink/basic.py.test +++ b/test/unlink/basic.py.test @@ -14,7 +14,7 @@ gh_submit("Initial 2") if is_direct(): assert_github_state( """\ - [O] #500 Commit A (gh/ezyang/1/head -> master) + [O] #500 Commit A (gh/ezyang/1/head -> main) This is commit A @@ -26,7 +26,7 @@ if is_direct(): * 30b9f2a Initial 1 - [O] #502 Commit A (gh/ezyang/3/head -> master) + [O] #502 Commit A (gh/ezyang/3/head -> main) This is commit A @@ -54,7 +54,7 @@ if is_direct(): | | Initial 2 | * 2193fd2 (gh/ezyang/3/next, gh/ezyang/3/head) |/ Initial 2 - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) @@ -119,7 +119,7 @@ else: | | Initial 2 | * c05297f (gh/ezyang/4/base) |/ Initial 2 (base update) - * dc8bfe4 (HEAD -> master) + * dc8bfe4 (HEAD -> main) Initial commit """ ) From 95e5abfc673350b55b16ebd42c2936e0c68c8c18 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 10 May 2026 12:58:20 -0400 Subject: [PATCH 7/7] Update [ghstack-poisoned] --- src/ghstack/github_fake.py | 49 +++++++------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/ghstack/github_fake.py b/src/ghstack/github_fake.py index 4df0184..3072c47 100644 --- a/src/ghstack/github_fake.py +++ b/src/ghstack/github_fake.py @@ -424,7 +424,7 @@ async def _update_pull_async( if "body" in input and input["body"] is not None: pr.body = input["body"] - def _create_issue_comment( + async def _create_issue_comment_async( self, owner: str, name: str, comment_id: int, input: CreateIssueCommentInput ) -> CreateIssueCommentPayload: state = self.state @@ -444,7 +444,7 @@ def _create_issue_comment( "id": comment_id, } - def _update_issue_comment( + async def _update_issue_comment_async( self, owner: str, name: str, comment_id: int, input: UpdateIssueCommentInput ) -> None: state = self.state @@ -467,7 +467,7 @@ async def _set_default_branch_async( async def arest(self, method: str, path: str, **kwargs: Any) -> Any: return await self._arest_impl(method, path, **kwargs) - def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: + async def _arest_impl(self, method: str, path: str, **kwargs: Any) -> Any: if method == "get": m = re.match(r"^repos/([^/]+)/([^/]+)/branches/([^/]+)/protection", path) if m: @@ -499,8 +499,12 @@ def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: } elif method == "post": + if m := re.match(r"^repos/([^/]+)/([^/]+)/pulls$", path): + return await self._create_pull_async( + m.group(1), m.group(2), cast(CreatePullRequestInput, kwargs) + ) if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/comments", path): - return self._create_issue_comment( + return await self._create_issue_comment_async( m.group(1), m.group(2), GitHubNumber(int(m.group(3))), @@ -524,41 +528,6 @@ def _rest_impl(self, method: str, path: str, **kwargs: Any) -> Any: labels = kwargs.get("labels", []) pr.labels.extend(labels) return {} - elif method == "patch": - if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/comments/([^/]+)$", path): - return self._update_issue_comment( - m.group(1), - m.group(2), - int(m.group(3)), - cast(UpdateIssueCommentInput, kwargs), - ) - raise NotImplementedError( - "FakeGitHubEndpoint REST {} {} not implemented".format(method.upper(), path) - ) - - async def _arest_impl(self, method: str, path: str, **kwargs: Any) -> Any: - if method == "get": - return self._rest_impl(method, path, **kwargs) - - elif method == "post": - if m := re.match(r"^repos/([^/]+)/([^/]+)/pulls$", path): - return await self._create_pull_async( - m.group(1), m.group(2), cast(CreatePullRequestInput, kwargs) - ) - if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/comments", path): - return self._create_issue_comment( - m.group(1), - m.group(2), - GitHubNumber(int(m.group(3))), - cast(CreateIssueCommentInput, kwargs), - ) - if m := re.match( - r"^repos/([^/]+)/([^/]+)/pulls/([^/]+)/requested_reviewers", path - ): - return self._rest_impl(method, path, **kwargs) - if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/([^/]+)/labels", path): - return self._rest_impl(method, path, **kwargs) - elif method == "patch": if m := re.match(r"^repos/([^/]+)/([^/]+)(?:/pulls/([^/]+))?$", path): owner, name, number = m.groups() @@ -574,7 +543,7 @@ async def _arest_impl(self, method: str, path: str, **kwargs: Any) -> Any: owner, name, cast(SetDefaultBranchInput, kwargs) ) if m := re.match(r"^repos/([^/]+)/([^/]+)/issues/comments/([^/]+)$", path): - return self._update_issue_comment( + return await self._update_issue_comment_async( m.group(1), m.group(2), int(m.group(3)),