-
Notifications
You must be signed in to change notification settings - Fork 79
feat(config): support watch key in TOML config #279
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -161,6 +161,52 @@ describe("config resolution", () => { | |
| expect(fallbackResolved.input.options.excludeUntracked).toBe(false); | ||
| }); | ||
|
|
||
| test("resolves watch from config unless CLI explicitly enables it", () => { | ||
| const cases: Array<{ | ||
| config: string; | ||
| cliOptions: Partial<CliInput["options"]>; | ||
| expected: boolean; | ||
| }> = [ | ||
| { | ||
| config: "watch = true\n", | ||
| cliOptions: {}, | ||
| expected: true, | ||
| }, | ||
| { | ||
| config: "watch = false\n", | ||
| cliOptions: {}, | ||
| expected: false, | ||
| }, | ||
| { | ||
| config: "", | ||
| cliOptions: {}, | ||
| expected: false, | ||
| }, | ||
| { | ||
| config: "watch = false\n", | ||
| cliOptions: { watch: true }, | ||
| expected: true, | ||
| }, | ||
| ]; | ||
|
|
||
| for (const entry of cases) { | ||
| const home = createTempDir("hunk-config-home-"); | ||
| mkdirSync(join(home, ".config", "hunk"), { recursive: true }); | ||
| writeFileSync(join(home, ".config", "hunk", "config.toml"), entry.config); | ||
|
|
||
| const resolved = resolveConfiguredCliInput( | ||
| { | ||
| kind: "vcs", | ||
| staged: false, | ||
| options: entry.cliOptions, | ||
| }, | ||
| { cwd: createTempDir("hunk-config-cwd-"), env: { HOME: home } }, | ||
| ); | ||
|
|
||
| expect(resolved.input.options.watch).toBe(entry.expected); | ||
| } | ||
| }); | ||
|
Comment on lines
+164
to
+208
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The resolution table covers four of the five meaningful cells but omits the case Prompt To Fix With AIThis is a comment left during a code review.
Path: src/core/config.test.ts
Line: 164-208
Comment:
**Missing test case: TOML watch=true with CLI watch=false**
The resolution table covers four of the five meaningful cells but omits the case `{ config: "watch = true\n", cliOptions: { watch: false }, expected: false }` — CLI explicitly suppressing a config-enabled watch. If `CommonOptions.watch` can legitimately be `false` rather than `undefined` (e.g. a future `--no-watch` flag or a programmatic caller that sets it explicitly), the final override expression `input.options.watch ?? resolvedOptions.watch ?? false` would return `false` correctly, but this is untested. Adding the case would lock in that behavior and make the intent of `??` vs `&&` clear for future readers.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| test("defaults to git VCS mode and accepts jj from config", () => { | ||
| const home = createTempDir("hunk-config-home-"); | ||
| mkdirSync(join(home, ".config", "hunk"), { recursive: true }); | ||
|
|
||
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.
The
forloop means that if the firstexpectthrows, Bun reports only one failure and skips the remaining three cases. Usingtest.each(or Bun'sdescribe.each) would make each cell an independent test so all failing cases surface together — the same pattern would also be more consistent with how the other parametric tests in this project are typically structured.Prompt To Fix With AI