-
Notifications
You must be signed in to change notification settings - Fork 300
fix(USE-001): use ERR_SYSTEM constant in generate_git_patch.cjs #18877
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -324,6 +324,44 @@ describe("sanitizeBranchNameForPatch", () => { | |||||||||||||
| }); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| describe("generateGitPatch - standardized error codes", () => { | ||||||||||||||
| let originalEnv; | ||||||||||||||
|
|
||||||||||||||
| beforeEach(() => { | ||||||||||||||
| originalEnv = { | ||||||||||||||
| GITHUB_SHA: process.env.GITHUB_SHA, | ||||||||||||||
| GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE, | ||||||||||||||
| }; | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| afterEach(() => { | ||||||||||||||
| Object.keys(originalEnv).forEach(key => { | ||||||||||||||
| if (originalEnv[key] !== undefined) { | ||||||||||||||
| process.env[key] = originalEnv[key]; | ||||||||||||||
| } else { | ||||||||||||||
| delete process.env[key]; | ||||||||||||||
| } | ||||||||||||||
| }); | ||||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| it("should fail gracefully and return a non-empty error string when no commits can be found", async () => { | ||||||||||||||
| const { generateGitPatch } = await import("./generate_git_patch.cjs"); | ||||||||||||||
|
|
||||||||||||||
| process.env.GITHUB_WORKSPACE = "/tmp/nonexistent-repo"; | ||||||||||||||
| process.env.GITHUB_SHA = "abc123"; | ||||||||||||||
|
|
||||||||||||||
| const result = await generateGitPatch("feature-branch", "main"); | ||||||||||||||
|
|
||||||||||||||
| expect(result.success).toBe(false); | ||||||||||||||
| expect(result).toHaveProperty("error"); | ||||||||||||||
| // Note: E005 is used as an internal control-flow signal in Strategy 1 (full mode) | ||||||||||||||
| // and is caught before reaching the final return value. The conformance check | ||||||||||||||
| // validates the E005 code at source level via check-safe-outputs-conformance.sh. | ||||||||||||||
|
Comment on lines
+357
to
+359
|
||||||||||||||
| // Note: E005 is used as an internal control-flow signal in Strategy 1 (full mode) | |
| // and is caught before reaching the final return value. The conformance check | |
| // validates the E005 code at source level via check-safe-outputs-conformance.sh. | |
| // Note: ERR_SYSTEM is used as an internal control-flow signal in Strategy 1 (full mode) | |
| // and is caught before reaching the final return value. The conformance check | |
| // validates the ERR_SYSTEM prefix at source level via check-safe-outputs-conformance.sh. |
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.
This new test doesn’t appear to exercise the specific Strategy 1 (full mode) branch where
No remote refs available...is thrown: settingGITHUB_WORKSPACEto a nonexistent path causes git commands to fail earlier (similar to the existing cross-repo tests above), so it won’t cover the newly prefixedthrowline. Consider creating a minimal temporary git repo with a localfeature-branchbut noorigin/*refs (or mockingexecGitSync) so the code reaches the intended fallback/throw path, or otherwise adjust the PR description/test name to reflect what’s actually being validated.