codex-review-mcp 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,8 +54,14 @@ export async function collectDiff(input, workspaceDir) {
|
|
54
54
|
// Branch doesn't exist, try next
|
55
55
|
}
|
56
56
|
}
|
57
|
-
// Last resort: use HEAD~1 as baseline
|
58
|
-
|
57
|
+
// Last resort: use HEAD~1 as baseline if it exists
|
58
|
+
try {
|
59
|
+
await exec('git', ['rev-parse', '--verify', 'HEAD~1'], { cwd: repoRoot });
|
60
|
+
return 'HEAD~1';
|
61
|
+
}
|
62
|
+
catch {
|
63
|
+
return null;
|
64
|
+
}
|
59
65
|
}
|
60
66
|
async function hasUncommittedChanges(repoRoot) {
|
61
67
|
try {
|
@@ -75,6 +81,15 @@ export async function collectDiff(input, workspaceDir) {
|
|
75
81
|
return null;
|
76
82
|
}
|
77
83
|
}
|
84
|
+
async function hasHeadCommit(repoRoot) {
|
85
|
+
try {
|
86
|
+
await exec('git', ['rev-parse', '--verify', 'HEAD'], { cwd: repoRoot });
|
87
|
+
return true;
|
88
|
+
}
|
89
|
+
catch {
|
90
|
+
return false;
|
91
|
+
}
|
92
|
+
}
|
78
93
|
// Priority order: explicit workspaceDir param > env vars > process.cwd()
|
79
94
|
const preferredStart = workspaceDir || process.env.CODEX_REPO_ROOT || process.env.WORKSPACE_ROOT || process.env.INIT_CWD || process.cwd();
|
80
95
|
const preferredRoot = await findRepoRoot(preferredStart);
|
@@ -88,13 +103,22 @@ export async function collectDiff(input, workspaceDir) {
|
|
88
103
|
// Auto mode: detect what to review
|
89
104
|
const hasChanges = await hasUncommittedChanges(repoRoot);
|
90
105
|
if (hasChanges) {
|
91
|
-
// Review uncommitted changes vs HEAD
|
92
|
-
|
106
|
+
// Review uncommitted changes vs HEAD (or staged if no commits yet)
|
107
|
+
if (await hasHeadCommit(repoRoot)) {
|
108
|
+
args.push('HEAD');
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
args.splice(1, 0, '--staged');
|
112
|
+
}
|
93
113
|
}
|
94
114
|
else {
|
95
115
|
// No uncommitted changes, review branch vs default
|
96
116
|
const currentBranch = await getCurrentBranch(repoRoot);
|
97
117
|
const defaultBranch = await detectDefaultBranch(repoRoot);
|
118
|
+
if (!defaultBranch) {
|
119
|
+
// Can't determine default branch - nothing to review
|
120
|
+
return '';
|
121
|
+
}
|
98
122
|
if (currentBranch === defaultBranch) {
|
99
123
|
// On default branch with no changes - nothing to review
|
100
124
|
return '';
|