mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
fix: match label_trigger case-insensitively (#1576)
label_trigger used a case-sensitive exact comparison, so a workflow configured with label_trigger: "claude-task" did not fire when an issue received a label named "Claude-Task" (the same label name with different casing). GitHub label names are unique without regard to case, so comparing without case is unambiguous. It also matches the trigger_phrase check in the same function, which is already case-insensitive. Compare labelName and labelTrigger with toLowerCase(), and add a test covering a mixed-case label. Fixes #1571
This commit is contained in:
@@ -38,7 +38,10 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
if (isIssuesEvent(context) && context.eventAction === "labeled") {
|
if (isIssuesEvent(context) && context.eventAction === "labeled") {
|
||||||
const labelName = (context.payload as any).label?.name || "";
|
const labelName = (context.payload as any).label?.name || "";
|
||||||
|
|
||||||
if (labelTrigger && labelName === labelTrigger) {
|
if (
|
||||||
|
labelTrigger &&
|
||||||
|
labelName.toLowerCase() === labelTrigger.toLowerCase()
|
||||||
|
) {
|
||||||
console.log(`Issue labeled with trigger label '${labelTrigger}'`);
|
console.log(`Issue labeled with trigger label '${labelTrigger}'`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,20 @@ describe("checkContainsTrigger", () => {
|
|||||||
expect(checkContainsTrigger(context)).toBe(false);
|
expect(checkContainsTrigger(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return true when the labeled name differs only in case from the trigger", () => {
|
||||||
|
const context = {
|
||||||
|
...mockIssueLabeledContext,
|
||||||
|
payload: {
|
||||||
|
...mockIssueLabeledContext.payload,
|
||||||
|
label: {
|
||||||
|
...(mockIssueLabeledContext.payload as any).label,
|
||||||
|
name: "Claude-Task",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as ParsedGitHubContext;
|
||||||
|
expect(checkContainsTrigger(context)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it("should return false for non-labeled events", () => {
|
it("should return false for non-labeled events", () => {
|
||||||
const context = {
|
const context = {
|
||||||
...mockIssueLabeledContext,
|
...mockIssueLabeledContext,
|
||||||
|
|||||||
Reference in New Issue
Block a user