mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-05-22 10:55:54 +00:00
feat: rename placeholder from {path} to {{{content}}}
Agent-Logs-Url: https://github.com/marocchino/sticky-pull-request-comment/sessions/72744cd4-264e-4c06-95d4-6fdec3446f90 Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
4bbfc023b8
commit
207e3732e6
4 changed files with 15 additions and 15 deletions
|
|
@ -114,7 +114,7 @@ with:
|
|||
|
||||
### Embed file content inside a message template
|
||||
|
||||
Use `{path}` as a placeholder in the `message` to insert file content at that position.
|
||||
Use `{{{content}}}` as a placeholder in the `message` to insert file content at that position.
|
||||
|
||||
````yaml
|
||||
- name: Run Test
|
||||
|
|
@ -124,7 +124,7 @@ Use `{path}` as a placeholder in the `message` to insert file content at that po
|
|||
path: result.txt
|
||||
message: |
|
||||
```
|
||||
{path}
|
||||
{{{content}}}
|
||||
```
|
||||
````
|
||||
|
||||
|
|
@ -236,11 +236,11 @@ For more detailed information about permissions, you can read from the link belo
|
|||
|
||||
### `message`
|
||||
|
||||
**Optional** Comment message. When used together with `path`, use `{path}` as a placeholder in the message where the file content should be inserted.
|
||||
**Optional** Comment message. When used together with `path`, use `{{{content}}}` as a placeholder in the message where the file content should be inserted.
|
||||
|
||||
### `path`
|
||||
|
||||
**Optional** Path to file containing comment message. When `message` is also provided and contains `{path}`, the file content is embedded at that placeholder position.
|
||||
**Optional** Path to file containing comment message. When `message` is also provided and contains `{{{content}}}`, the file content is embedded at that placeholder position.
|
||||
|
||||
### `number`
|
||||
|
||||
|
|
|
|||
|
|
@ -211,11 +211,11 @@ describe("getBody", () => {
|
|||
expect(core.setFailed).toHaveBeenCalledWith("glob error")
|
||||
})
|
||||
|
||||
test("embeds file content in message when {path} placeholder is used", async () => {
|
||||
test("embeds file content in message when {{{content}}} placeholder is used", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "```\n{path}\n```"
|
||||
if (name === "message") return "```\n{{{content}}}\n```"
|
||||
return ""
|
||||
})
|
||||
mockGlobCreate.mockResolvedValue({
|
||||
|
|
@ -224,11 +224,11 @@ describe("getBody", () => {
|
|||
expect(await config.getBody()).toBe("```\nhi there\n\n```")
|
||||
})
|
||||
|
||||
test("replaces all {path} occurrences in message with file content", async () => {
|
||||
test("replaces all {{{content}}} occurrences in message with file content", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "{path}\n---\n{path}"
|
||||
if (name === "message") return "{{{content}}}\n---\n{{{content}}}"
|
||||
return ""
|
||||
})
|
||||
mockGlobCreate.mockResolvedValue({
|
||||
|
|
@ -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 {path} placeholder", async () => {
|
||||
test("uses file content 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 => {
|
||||
|
|
@ -250,11 +250,11 @@ describe("getBody", () => {
|
|||
expect(await config.getBody()).toBe("hi there\n")
|
||||
})
|
||||
|
||||
test("embeds multiple files content in message when {path} placeholder is used", async () => {
|
||||
test("embeds multiple files content in message when {{{content}}} placeholder is used", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/*"])
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "```\n{path}\n```"
|
||||
if (name === "message") return "```\n{{{content}}}\n```"
|
||||
return ""
|
||||
})
|
||||
mockGlobCreate.mockResolvedValue({
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ inputs:
|
|||
default: "OUTDATED"
|
||||
required: false
|
||||
message:
|
||||
description: "comment message. When used together with path, use `{path}` as a placeholder in the message where the file content should be inserted."
|
||||
description: "comment message. When used together with path, use `{{{content}}}` as a placeholder in the message where the file content should be inserted."
|
||||
required: false
|
||||
path:
|
||||
description: "glob path to file(s) containing comment message. When message is also provided and contains `{path}`, the file content is embedded at that placeholder position."
|
||||
description: "glob path to file(s) containing comment message. When message is also provided and contains `{{{content}}}`, the file content is embedded at that placeholder position."
|
||||
required: false
|
||||
ignore_empty:
|
||||
description: "Indicates whether to ignore missing or empty messages"
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ export async function getBody(): Promise<string> {
|
|||
const fileContent = (await globber.glob())
|
||||
.map(path => readFileSync(path, "utf-8"))
|
||||
.join("\n")
|
||||
if (messageInput && messageInput.includes("{path}")) {
|
||||
return messageInput.replace(/\{path\}/g, fileContent)
|
||||
if (messageInput && messageInput.includes("{{{content}}}")) {
|
||||
return messageInput.replace(/\{\{\{content\}\}\}/g, fileContent)
|
||||
}
|
||||
return fileContent
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue