-
Notifications
You must be signed in to change notification settings - Fork 10
feat(freeze): add scheduled freeze CLI commands #993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mergify
merged 1 commit into
main
from
devs/jd/worktree-scheduled-freeze/I414d168066f7b5070e75520bdcbb8189d694ad72
Mar 6, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import typing | ||
|
|
||
|
|
||
| if typing.TYPE_CHECKING: | ||
| import datetime | ||
| import uuid | ||
|
|
||
| import httpx | ||
|
|
||
|
|
||
| class ScheduledFreezeResponse(typing.TypedDict, total=False): | ||
| id: typing.Required[str] | ||
| reason: typing.Required[str] | ||
| start: typing.Required[str] | ||
| end: typing.Required[str | None] | ||
| timezone: typing.Required[str] | ||
| matching_conditions: typing.Required[list[str]] | ||
| exclude_conditions: list[str] | ||
|
|
||
|
|
||
| class CreateScheduledFreezePayload(typing.TypedDict, total=False): | ||
| reason: typing.Required[str] | ||
| start: typing.Required[str | None] | ||
| end: typing.Required[str | None] | ||
| timezone: typing.Required[str] | ||
| matching_conditions: typing.Required[list[str]] | ||
| exclude_conditions: list[str] | ||
|
|
||
|
|
||
| class UpdateScheduledFreezePayload(typing.TypedDict, total=False): | ||
| reason: str | None | ||
| start: str | None | ||
| end: str | None | ||
| timezone: str | None | ||
| matching_conditions: list[str] | None | ||
| exclude_conditions: list[str] | None | ||
|
|
||
|
|
||
| async def list_freezes( | ||
| client: httpx.AsyncClient, | ||
| repository: str, | ||
| ) -> list[ScheduledFreezeResponse]: | ||
| response = await client.get( | ||
| f"/v1/repos/{repository}/scheduled_freeze", | ||
| ) | ||
| data: dict[str, list[ScheduledFreezeResponse]] = response.json() | ||
| return data["scheduled_freezes"] | ||
|
|
||
|
|
||
| async def create_freeze( | ||
| client: httpx.AsyncClient, | ||
| repository: str, | ||
| *, | ||
| reason: str, | ||
| timezone: str, | ||
| matching_conditions: list[str], | ||
| start: datetime.datetime | None = None, | ||
| end: datetime.datetime | None = None, | ||
| exclude_conditions: list[str] | None = None, | ||
| ) -> ScheduledFreezeResponse: | ||
| payload: CreateScheduledFreezePayload = { | ||
| "reason": reason, | ||
| "start": start.isoformat() if start is not None else None, | ||
| "end": end.isoformat() if end is not None else None, | ||
| "timezone": timezone, | ||
| "matching_conditions": matching_conditions, | ||
| } | ||
| if exclude_conditions: | ||
| payload["exclude_conditions"] = exclude_conditions | ||
|
|
||
| response = await client.post( | ||
| f"/v1/repos/{repository}/scheduled_freeze", | ||
| json=payload, | ||
| ) | ||
| return response.json() # type: ignore[no-any-return] | ||
|
|
||
|
|
||
| async def update_freeze( | ||
| client: httpx.AsyncClient, | ||
| repository: str, | ||
| freeze_id: uuid.UUID, | ||
| *, | ||
| reason: str | None = None, | ||
| timezone: str | None = None, | ||
| matching_conditions: list[str] | None = None, | ||
| start: datetime.datetime | None = None, | ||
| end: datetime.datetime | None = None, | ||
| exclude_conditions: list[str] | None = None, | ||
| ) -> ScheduledFreezeResponse: | ||
| payload: UpdateScheduledFreezePayload = {} | ||
| if reason is not None: | ||
| payload["reason"] = reason | ||
| if timezone is not None: | ||
| payload["timezone"] = timezone | ||
| if matching_conditions is not None: | ||
| payload["matching_conditions"] = matching_conditions | ||
| if start is not None: | ||
| payload["start"] = start.isoformat() | ||
| if end is not None: | ||
| payload["end"] = end.isoformat() | ||
| if exclude_conditions is not None: | ||
| payload["exclude_conditions"] = exclude_conditions | ||
|
|
||
| response = await client.patch( | ||
| f"/v1/repos/{repository}/scheduled_freeze/{freeze_id}", | ||
| json=payload, | ||
| ) | ||
| return response.json() # type: ignore[no-any-return] | ||
|
|
||
|
|
||
| async def delete_freeze( | ||
| client: httpx.AsyncClient, | ||
| repository: str, | ||
| freeze_id: uuid.UUID, | ||
| *, | ||
| delete_reason: str | None = None, | ||
| ) -> None: | ||
| url = f"/v1/repos/{repository}/scheduled_freeze/{freeze_id}" | ||
| if delete_reason is not None: | ||
| await client.request( | ||
| "DELETE", | ||
| url, | ||
| json={"delete_reason": delete_reason}, | ||
| ) | ||
| else: | ||
| await client.delete(url) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.