feat: add only_update to exclusive modes validation list

Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-13 11:53:25 +00:00
parent da6fd3b3a2
commit f8ca6e99f5
2 changed files with 6 additions and 6 deletions

View file

@ -142,7 +142,7 @@ describe("run", () => {
mockConfig.onlyUpdateComment = true
const {core} = await runMain()
expect(core.setFailed).toHaveBeenCalledWith(
"only_create and only_update cannot be both set to true",
"only_create and only_update cannot be set to true simultaneously",
)
})

View file

@ -50,16 +50,16 @@ async function run(): Promise<undefined> {
["delete", deleteOldComment],
["recreate", recreate],
["only_create", onlyCreateComment],
["only_update", onlyUpdateComment],
["hide", hideOldComment],
["hide_and_recreate", hideAndRecreate],
]
const enabledModes = exclusiveModes.filter(([, flag]) => flag).map(([name]) => name)
if (enabledModes.length > 1) {
throw new Error(`${enabledModes.join(" and ")} cannot be set to true simultaneously`)
}
if (onlyCreateComment && onlyUpdateComment) {
throw new Error("only_create and only_update cannot be both set to true")
const last = enabledModes[enabledModes.length - 1]
const rest = enabledModes.slice(0, -1)
const joined = enabledModes.length === 2 ? `${rest[0]} and ${last}` : `${rest.join(", ")}, and ${last}`
throw new Error(`${joined} cannot be set to true simultaneously`)
}
const octokit = github.getOctokit(githubToken)