Skip to content

Commit 41bb78d

Browse files
snomiaoclaude
andauthored
feat(easylabel): add allowAdd and allowRemove patterns for controlled label operations (#57)
* feat(easylabel.tsx): add allowAdd and allowRemove patterns to control label operations for better validation fix(easylabel.tsx): implement checks to skip disallowed labels during addition and removal operations * feat(easylabel): add allowAdd and allowRemove patterns for controlled label operations - Add allowAdd and allowRemove string array patterns to EasyLabelProps - Implement label validation logic to skip disallowed operations - Prevent label addition when not in allowAdd patterns (if specified) - Prevent label removal when not in allowRemove patterns (if specified) - Maintain backward compatibility with existing usage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix(easylabel.tsx): remove unnecessary label pattern from allow array to simplify configuration and improve clarity * fix(easylabel.tsx): await createIndex to ensure proper execution of index creation before proceeding with other operations --------- Co-authored-by: Claude <[email protected]>
1 parent 58a11e9 commit 41bb78d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

run/easylabel.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const cfg = {
3030
"https://github.com/Comfy-Org/ComfyUI_frontend",
3131
"https://github.com/Comfy-Org/desktop",
3232
],
33-
coreLabels: ["Core", "Core-Important", "Core-Ready-for-Review"],
33+
// allow all users to edit bugcop:*, area:*, Core-*, labels
34+
allow: [/^(?:Core|Core-.*)$/, /^(?:bug-cop|area):.*$/],
3435
};
3536
type GithubIssueLabelOps = {
3637
target_url: string; // can be comment or issue
@@ -42,7 +43,7 @@ type GithubIssueLabelOps = {
4243
};
4344

4445
const GithubIssueLabelOps = db.collection<GithubIssueLabelOps>("GithubIssueLabelOps");
45-
GithubIssueLabelOps.createIndex({ target_url: 1 }, { unique: true });
46+
await GithubIssueLabelOps.createIndex({ target_url: 1 }, { unique: true });
4647

4748
const saveTask = async (task: Partial<GithubIssueLabelOps> & { target_url: string }) =>
4849
(await GithubIssueLabelOps.findOneAndUpdate(
@@ -112,6 +113,9 @@ export async function processIssueCommentForLableops({
112113
// skip already added/removed in issueLables
113114
if (op === "+" && issueLabels.includes(name)) return false;
114115
if (op === "-" && !issueLabels.includes(name)) return false;
116+
// skip not allowed labels
117+
if (op === "+" && !cfg.allow.some((pattern) => name.match(pattern))) return false;
118+
if (op === "-" && !cfg.allow.some((pattern) => name.match(pattern))) return false;
115119
return true;
116120
});
117121

0 commit comments

Comments
 (0)