fix: when message has no {{{content}}} placeholder, return message as-is

Agent-Logs-Url: https://github.com/marocchino/sticky-pull-request-comment/sessions/b6492aa3-c55c-41f7-b43e-12cc3f2c3002

Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-24 12:16:39 +00:00 committed by GitHub
parent 207e3732e6
commit c9b1ea3b58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 4 deletions

View file

@ -237,7 +237,7 @@ describe("getBody", () => {
expect(await config.getBody()).toBe("hi there\n\n---\nhi there\n")
})
test("uses file content as body when path is provided but message has no {{{content}}} placeholder", async () => {
test("uses message as body when path is provided but message has no {{{content}}} placeholder", async () => {
const {config, core} = await loadConfig()
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
vi.mocked(core.getInput).mockImplementation(name => {
@ -247,7 +247,7 @@ describe("getBody", () => {
mockGlobCreate.mockResolvedValue({
glob: vi.fn().mockResolvedValue([resolve("__tests__/assets/result")]),
})
expect(await config.getBody()).toBe("hi there\n")
expect(await config.getBody()).toBe("no placeholder here")
})
test("embeds multiple files content in message when {{{content}}} placeholder is used", async () => {

View file

@ -61,8 +61,11 @@ export async function getBody(): Promise<string> {
const fileContent = (await globber.glob())
.map(path => readFileSync(path, "utf-8"))
.join("\n")
if (messageInput && messageInput.includes("{{{content}}}")) {
return messageInput.replace(/\{\{\{content\}\}\}/g, fileContent)
if (messageInput) {
if (messageInput.includes("{{{content}}}")) {
return messageInput.replace(/\{\{\{content\}\}\}/g, fileContent)
}
return messageInput
}
return fileContent
} catch (error) {