-
Notifications
You must be signed in to change notification settings - Fork 3
refactor three component #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
leavesster
commented
Sep 26, 2025
- refactor: use three componet
- test: update test case
Summary by CodeRabbit
Walkthrough将凭证格式由两段改为三段。更新 CredentialInput 构造函数签名与内部表示;调整 generateCredentialInput 解析与校验逻辑以按逗号分割并验证三段;更新 replaceCredential 调用;相应地重写并扩展单元测试以覆盖三段格式与无效输入场景。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/executor/src/credential.ts (1)
18-29: 健壮性:建议 trim 三段,兼容空白字符当前带空格的片段会被原样接收,可能导致下游匹配失败;建议在拆分后 trim 再校验非空。
- const parts = content.split(","); + const parts = content.split(","); if (parts.length !== 3) { return null; } - - const [type, name, id] = parts; - if (!type || !name || !id) { + const [type, name, id] = parts.map((s) => s.trim()); + if (!type || !name || !id) { return null; } return new CredentialInput(type, name, id);另可移除魔法数字 17/-2,使用常量提升可读性(非本变更行,示意如下):
const PREFIX = "${{OO_CREDENTIAL:"; const SUFFIX = "}}"; if (!credentialPath.startsWith(PREFIX) || !credentialPath.endsWith(SUFFIX)) return null; const content = credentialPath.slice(PREFIX.length, -SUFFIX.length).trim();packages/executor/test/credential.test.ts (1)
29-33: 空片段用例覆盖到位;建议补充空白字符用例当前已覆盖空字符串,建议新增包含空格的用例,配合实现层 trim 改进:
it("should trim spaces around parts", () => { expect(generateCredentialInput("${{OO_CREDENTIAL: github, token , my-token }}")) .toEqual(new CredentialInput("github", "token", "my-token")); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/executor/src/credential.ts(2 hunks)packages/executor/test/credential.test.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/executor/test/credential.test.ts (1)
packages/executor/src/credential.ts (3)
generateCredentialInput(8-29)CredentialInput(4-6)replaceCredential(31-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: check
🔇 Additional comments (10)
packages/executor/test/credential.test.ts (9)
7-10: 三段解析用例合理覆盖标准三段路径解析,断言准确。
12-15: 特字符用例合理验证连字符等常见字符,断言准确。
22-23: 两段输入判空逻辑覆盖到位两段应返回 null,符合预期。
25-27: 超出三段的异常用例覆盖到位多段输入返回 null,符合预期。
39-39: 替换输入的三段格式示例清晰输入样例与 schema 搭配合理。
61-61: 替换结果断言正确与新的三段构造保持一致。
67-67: 非 credential 类型不替换的前置条件设置合理与 isCredentialSchema 语义一致。
81-82: 保持原值的断言正确非 credential 类型保持字符串原样。
84-101: 无效格式不替换的用例完整验证 replaceCredential 对无效路径的幂等性,符合预期。
packages/executor/src/credential.ts (1)
5-5: 确认:无两参调用及 .value 引用
已验证所有 new CredentialInput 均为三参,且未发现 .value 使用。
* refactor: use three componet * test: update test case * remove magic number