2626import os
2727from typing import Any
2828
29- from hackbot_runtime .actions .email import PATCH_PLACEHOLDER
30- from hackbot_runtime .actions .handlers .base import ActionResult , ApplyContext
31- from hackbot_runtime .changes import PATCH_ARTIFACT
29+ from app .action_handlers .base import ActionResult , ApplyContext
3230
3331log = logging .getLogger (__name__ )
3432
33+ # Artifact containing a run's source-code patch.
34+ _PATCH_ARTIFACT = "changes/changes.patch"
35+
36+ # Email-body token replaced with the source-code patch.
37+ PATCH_PLACEHOLDER = "{patch}"
38+
3539# A diff long enough to bury the rest of the mail is cut off; the attachment,
3640# when the caller asked for one, still carries every line.
3741_MAX_PATCH_LINES = 400
@@ -56,7 +60,7 @@ async def _patch(ctx: ApplyContext) -> bytes | None:
5660 recipient the patch, not the whole notification.
5761 """
5862 try :
59- return await ctx .download_artifact (PATCH_ARTIFACT )
63+ return await ctx .download_artifact (_PATCH_ARTIFACT )
6064 except Exception :
6165 log .exception ("Could not read the patch of run %s" , ctx .run_id )
6266 return None
@@ -127,7 +131,7 @@ async def apply(self, params: dict[str, Any], ctx: ApplyContext) -> ActionResult
127131 message .add_attachment (
128132 Attachment (
129133 FileContent (base64 .b64encode (patch ).decode ()),
130- FileName (PATCH_ARTIFACT .rsplit ("/" , 1 )[- 1 ]),
134+ FileName (_PATCH_ARTIFACT .rsplit ("/" , 1 )[- 1 ]),
131135 disposition = Disposition ("attachment" ),
132136 )
133137 )
0 commit comments