Skip to content

fix: use merge path for users of oh my zsh#1943

Open
k11kirky wants to merge 1 commit intomainfrom
04-29-fix_use_merge_path_for_users_of_oh_my_zsh
Open

fix: use merge path for users of oh my zsh#1943
k11kirky wants to merge 1 commit intomainfrom
04-29-fix_use_merge_path_for_users_of_oh_my_zsh

Conversation

@k11kirky
Copy link
Copy Markdown
Contributor

@k11kirky k11kirky commented Apr 29, 2026

Problem

Changes

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@k11kirky k11kirky marked this pull request as ready for review April 29, 2026 14:35
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 29, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/code/src/main/utils/fixPath.test.ts
Line: 69-164

Comment:
**Prefer parameterised tests for shared assertion patterns**

Tests `"merges fallback paths when shell PATH lacks /opt/homebrew/bin"` (line 69), `"falls back to fallback paths when shell resolution fails entirely"` (line 92), and `"merges fallback paths into a cached PATH that lacks them"` (line 106) all end with the same four `toContain` assertions for the fallback paths. Per the team's stated preference for parameterised tests, these cases could be collapsed into a single `it.each` that varies the mock setup (shell success / shell fail / cache hit) while sharing the assertion block, eliminating the duplication.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: use merge path for users of oh my z..." | Re-trigger Greptile

Comment on lines +69 to +164

it("merges fallback paths when shell PATH lacks /opt/homebrew/bin", async () => {
mockSpawnSync.mockReturnValue({
status: 0,
stdout: shellOutput("/usr/local/bin:/usr/bin:/bin"),
});

const { fixPath } = await import("./fixPath");
fixPath();

const parts = process.env.PATH?.split(":") ?? [];
expect(parts).toContain("/opt/homebrew/bin");
expect(parts).toContain("/opt/homebrew/sbin");
expect(parts).toContain("/usr/local/bin");
expect(parts).toContain("/usr/bin");
});

it("does not duplicate fallback paths already present in shell PATH", async () => {
mockSpawnSync.mockReturnValue({
status: 0,
stdout: shellOutput("/opt/homebrew/bin:/usr/local/bin:/usr/bin"),
});

const { fixPath } = await import("./fixPath");
fixPath();

const parts = process.env.PATH?.split(":") ?? [];
const homebrewCount = parts.filter((p) => p === "/opt/homebrew/bin").length;
expect(homebrewCount).toBe(1);
const usrLocalCount = parts.filter((p) => p === "/usr/local/bin").length;
expect(usrLocalCount).toBe(1);
});

it("falls back to fallback paths when shell resolution fails entirely", async () => {
mockSpawnSync.mockReturnValue({ status: 1, stdout: "" });

const { fixPath } = await import("./fixPath");
fixPath();

const parts = process.env.PATH?.split(":") ?? [];
expect(parts).toContain("/opt/homebrew/bin");
expect(parts).toContain("/opt/homebrew/sbin");
expect(parts).toContain("/usr/local/bin");
expect(parts).toContain("/usr/bin");
});

it("merges fallback paths into a cached PATH that lacks them", async () => {
mockExistsSync.mockReturnValue(true);
mockReadFileSync.mockReturnValue(
JSON.stringify({
path: "/usr/local/bin:/usr/bin:/bin",
timestamp: Date.now(),
}),
);

const { fixPath } = await import("./fixPath");
fixPath();

const parts = process.env.PATH?.split(":") ?? [];
expect(parts).toContain("/opt/homebrew/bin");
expect(mockSpawnSync).not.toHaveBeenCalled();
});

it("ignores stale cache and re-resolves via shell", async () => {
mockExistsSync.mockReturnValue(true);
mockReadFileSync.mockReturnValue(
JSON.stringify({
path: "/some/old/path",
timestamp: Date.now() - 2 * 60 * 60 * 1000,
}),
);
mockSpawnSync.mockReturnValue({
status: 0,
stdout: shellOutput("/usr/local/bin:/usr/bin"),
});

const { fixPath } = await import("./fixPath");
fixPath();

expect(mockSpawnSync).toHaveBeenCalled();
const parts = process.env.PATH?.split(":") ?? [];
expect(parts).not.toContain("/some/old/path");
expect(parts).toContain("/opt/homebrew/bin");
});

it("returns early on win32 without touching PATH", async () => {
setPlatform("win32");
process.env.PATH = "C:\\Windows\\System32";

const { fixPath } = await import("./fixPath");
fixPath();

expect(mockSpawnSync).not.toHaveBeenCalled();
expect(process.env.PATH).toBe("C:\\Windows\\System32");
});
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Prefer parameterised tests for shared assertion patterns

Tests "merges fallback paths when shell PATH lacks /opt/homebrew/bin" (line 69), "falls back to fallback paths when shell resolution fails entirely" (line 92), and "merges fallback paths into a cached PATH that lacks them" (line 106) all end with the same four toContain assertions for the fallback paths. Per the team's stated preference for parameterised tests, these cases could be collapsed into a single it.each that varies the mock setup (shell success / shell fail / cache hit) while sharing the assertion block, eliminating the duplication.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/main/utils/fixPath.test.ts
Line: 69-164

Comment:
**Prefer parameterised tests for shared assertion patterns**

Tests `"merges fallback paths when shell PATH lacks /opt/homebrew/bin"` (line 69), `"falls back to fallback paths when shell resolution fails entirely"` (line 92), and `"merges fallback paths into a cached PATH that lacks them"` (line 106) all end with the same four `toContain` assertions for the fallback paths. Per the team's stated preference for parameterised tests, these cases could be collapsed into a single `it.each` that varies the mock setup (shell success / shell fail / cache hit) while sharing the assertion block, eliminating the duplication.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant