Skip to content

Commit db52e28

Browse files
authored
Remove shell expansion for git commands (#447)
* Remove shell expansion for git commands * Version bump
1 parent 80c31f9 commit db52e28

8 files changed

Lines changed: 40 additions & 10 deletions

File tree

‎.claude-plugin/marketplace.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
},
66
"metadata": {
77
"description": "Codex plugins to use in Claude Code for delegation and code review.",
8-
"version": "1.0.5"
8+
"version": "1.0.6"
99
},
1010
"plugins": [
1111
{
1212
"name": "codex",
1313
"description": "Use Codex from Claude Code to review code or delegate tasks.",
14-
"version": "1.0.5",
14+
"version": "1.0.6",
1515
"author": {
1616
"name": "OpenAI"
1717
},

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openai/codex-plugin-cc",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"private": true,
55
"type": "module",
66
"description": "Use Codex from Claude Code to review code or delegate tasks.",

‎plugins/codex/.claude-plugin/plugin.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codex",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Use Codex from Claude Code to review code or delegate tasks.",
55
"author": {
66
"name": "OpenAI"

‎plugins/codex/scripts/lib/git.mjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ const MAX_UNTRACKED_BYTES = 24 * 1024;
88
const DEFAULT_INLINE_DIFF_MAX_FILES = 2;
99
const DEFAULT_INLINE_DIFF_MAX_BYTES = 256 * 1024;
1010

11+
// Git is directly executable on Windows. Repository-derived arguments must never pass through a shell.
1112
function git(cwd, args, options = {}) {
12-
return runCommand("git", args, { cwd, ...options });
13+
return runCommand("git", args, { cwd, ...options, shell: false });
1314
}
1415

1516
function gitChecked(cwd, args, options = {}) {
16-
return runCommandChecked("git", args, { cwd, ...options });
17+
return runCommandChecked("git", args, { cwd, ...options, shell: false });
1718
}
1819

1920
function listUniqueFiles(...groups) {

‎plugins/codex/scripts/lib/process.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function runCommand(command, args = [], options = {}) {
99
input: options.input,
1010
maxBuffer: options.maxBuffer,
1111
stdio: options.stdio ?? "pipe",
12-
shell: process.platform === "win32" ? (process.env.SHELL || true) : false,
12+
shell: options.shell ?? (process.platform === "win32" ? (process.env.SHELL || true) : false),
1313
windowsHide: true
1414
});
1515

‎tests/git.test.mjs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,35 @@ test("resolveReviewTarget falls back to branch diff when repo is clean", () => {
3838
assert.match(context.content, /Branch Diff/);
3939
});
4040

41+
test("default branch names with special characters are passed to git literally", () => {
42+
const cwd = makeTempDir();
43+
const branchName = "main&branch-helper&x";
44+
const helperOutputPath = path.join(cwd, "branch-helper-output");
45+
initGitRepo(cwd);
46+
fs.writeFileSync(path.join(cwd, "branch-helper.cmd"), "@echo branch-helper>branch-helper-output\r\n");
47+
fs.writeFileSync(path.join(cwd, "app.js"), "console.log('base');\n");
48+
run("git", ["add", "app.js", "branch-helper.cmd"], { cwd });
49+
run("git", ["commit", "-m", "base"], { cwd });
50+
run("git", ["branch", "-m", branchName], { cwd, shell: false });
51+
run("git", ["update-ref", `refs/remotes/origin/${branchName}`, branchName], { cwd, shell: false });
52+
run("git", ["symbolic-ref", "refs/remotes/origin/HEAD", `refs/remotes/origin/${branchName}`], {
53+
cwd,
54+
shell: false
55+
});
56+
run("git", ["checkout", "-b", "feature/test"], { cwd });
57+
fs.writeFileSync(path.join(cwd, "app.js"), "console.log('feature');\n");
58+
run("git", ["add", "app.js"], { cwd });
59+
run("git", ["commit", "-m", "feature"], { cwd });
60+
61+
const target = resolveReviewTarget(cwd, {});
62+
const context = collectReviewContext(cwd, target);
63+
64+
assert.equal(target.mode, "branch");
65+
assert.equal(target.baseRef, branchName);
66+
assert.match(context.content, /Branch Diff/);
67+
assert.equal(fs.existsSync(helperOutputPath), false);
68+
});
69+
4170
test("resolveReviewTarget honors explicit base overrides", () => {
4271
const cwd = makeTempDir();
4372
initGitRepo(cwd);

‎tests/helpers.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function run(command, args, options = {}) {
1818
env: options.env,
1919
encoding: "utf8",
2020
input: options.input,
21-
shell: process.platform === "win32" && !path.isAbsolute(command),
21+
shell: options.shell ?? (process.platform === "win32" && !path.isAbsolute(command)),
2222
windowsHide: true
2323
});
2424
}

0 commit comments

Comments
 (0)