Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ghstack/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class NotFoundError(RuntimeError):
pass


class LicenseError(RuntimeError):
pass


class GitHubEndpoint(metaclass=ABCMeta):
@abstractmethod
def graphql(self, query: str, **kwargs: Any) -> Any:
Expand Down
5 changes: 5 additions & 0 deletions src/ghstack/github_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ def rest(self, method: str, path: str, **kwargs: Any) -> Any:

# 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):
if resp.status_code == 403 and "Upgrade to GitHub Pro" in r.get(
"message", ""
):
raise ghstack.github.LicenseError(pretty_json)

remaining_count = resp.headers.get("x-ratelimit-remaining")
reset_time = resp.headers.get("x-ratelimit-reset")

Expand Down
4 changes: 4 additions & 0 deletions src/ghstack/land.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def main(
needs_force = True
except ghstack.github.NotFoundError:
pass
except ghstack.github.LicenseError:
logging.warning(
"Failed to check branch protection (GitHub Pro required), skipping check."
)

orig_ref, closed = lookup_pr_to_orig_ref_and_closed(
github,
Expand Down