Skip to content

Commit 64ee1a3

Browse files
authored
Move the Phabricator patch action types into actions.phabricator (#7039)
1 parent d064aa4 commit 64ee1a3

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎libs/hackbot-runtime/hackbot_runtime/actions/phabricator.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121

2222
from hackbot_runtime.actions.recorder import ActionsRecorder, confirmation
2323

24+
SUBMIT_PATCH_ACTION_TYPE = "phabricator.submit_patch"
25+
UPDATE_PATCH_ACTION_TYPE = "phabricator.update_patch"
26+
2427
# Both patch actions submit the working directory's changes as a diff, so
2528
# anything gated on "this run submits a patch" — today the diff artifact built
2629
# in ``context.publish_changes`` — has to cover both types.
27-
PATCH_ACTION_TYPES = frozenset({"phabricator.submit_patch", "phabricator.update_patch"})
30+
PATCH_ACTION_TYPES = frozenset({SUBMIT_PATCH_ACTION_TYPE, UPDATE_PATCH_ACTION_TYPE})
2831

2932
_PHABRICATOR_TEST_PLAN_HEADER_RE = re.compile(
3033
r"^(?:Test Plan|Testplan|Tested|Tests):",
@@ -126,7 +129,7 @@ async def submit_patch(
126129
if parent_revision_id is not None:
127130
params["parent_revision_id"] = parent_revision_id
128131
action = recorder.record(
129-
"phabricator.submit_patch", params, reasoning=reasoning, ref=ref
132+
SUBMIT_PATCH_ACTION_TYPE, params, reasoning=reasoning, ref=ref
130133
)
131134
return confirmation(action)
132135

@@ -164,7 +167,7 @@ async def update_patch(
164167
association exactly as they are.
165168
"""
166169
action = recorder.record(
167-
"phabricator.update_patch",
170+
UPDATE_PATCH_ACTION_TYPE,
168171
{"revision_id": revision_id},
169172
reasoning=reasoning,
170173
)

‎libs/hackbot-runtime/hackbot_runtime/context.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
from pydantic_settings import BaseSettings, SettingsConfigDict
2626

2727
from hackbot_runtime import artifacts, changes
28-
from hackbot_runtime.actions.phabricator import PATCH_ACTION_TYPES
28+
from hackbot_runtime.actions.phabricator import (
29+
PATCH_ACTION_TYPES,
30+
SUBMIT_PATCH_ACTION_TYPE,
31+
)
2932
from hackbot_runtime.actions.recorder import ActionsRecorder
3033
from hackbot_runtime.actions.try_server import TRY_ACTION_TYPES, TRY_PUSH_ACTION_TYPE
3134
from hackbot_runtime.config import HackbotConfig, load_config
@@ -38,8 +41,6 @@
3841

3942
log = logging.getLogger("hackbot_runtime.context")
4043

41-
_SUBMIT_PATCH_ACTION_TYPE = "phabricator.submit_patch"
42-
4344

4445
def _default_run_id() -> str:
4546
"""A unique, sortable id for runs that don't get one from the platform.
@@ -54,7 +55,7 @@ def _default_run_id() -> str:
5455

5556
def _wip_commit_message(actions: list[dict]) -> str:
5657
"""The patch title, else the try push title, for the agent's uncommitted work."""
57-
for action_type in (_SUBMIT_PATCH_ACTION_TYPE, TRY_PUSH_ACTION_TYPE):
58+
for action_type in (SUBMIT_PATCH_ACTION_TYPE, TRY_PUSH_ACTION_TYPE):
5859
for action in actions:
5960
if action["type"] == action_type and action["params"]["title"]:
6061
return action["params"]["title"]

0 commit comments

Comments
 (0)