threadlines 0.2.20 → 0.2.21
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.
- package/dist/commands/check.js +1 -1
- package/dist/git/diff.js +29 -7
- package/package.json +1 -1
package/dist/commands/check.js
CHANGED
|
@@ -246,7 +246,7 @@ async function checkCommand(options) {
|
|
|
246
246
|
console.log('');
|
|
247
247
|
process.exit(0);
|
|
248
248
|
}
|
|
249
|
-
console.log(chalk_1.default.green(`✓ Found ${gitDiff.changedFiles.length} changed file(s)\n`));
|
|
249
|
+
console.log(chalk_1.default.green(`✓ Found ${gitDiff.changedFiles.length} changed file(s) (context: ${reviewContext})\n`));
|
|
250
250
|
// Log the files being sent
|
|
251
251
|
for (const file of gitDiff.changedFiles) {
|
|
252
252
|
logger_1.logger.info(` → ${file}`);
|
package/dist/git/diff.js
CHANGED
|
@@ -194,9 +194,13 @@ async function getPRDiff(repoRoot, targetBranch, logger) {
|
|
|
194
194
|
* This works regardless of CI checkout depth settings (depth=1 or depth=2).
|
|
195
195
|
*
|
|
196
196
|
* Strategy:
|
|
197
|
-
* 1. Get parent SHA
|
|
198
|
-
*
|
|
199
|
-
*
|
|
197
|
+
* 1. Get parent SHA using plumbing command (git cat-file -p) to read raw commit object
|
|
198
|
+
* - Plumbing commands ignore .git/shallow boundaries and show actual parent SHA
|
|
199
|
+
* - Porcelain commands (git show) respect shallow boundaries and hide parents in shallow clones
|
|
200
|
+
* - This is critical for CI environments that use shallow clones (depth=1)
|
|
201
|
+
* 2. Parse first parent line (handles standard commits and merge commits)
|
|
202
|
+
* 3. Fetch parent commit if available (git fetch origin <parentSHA> --depth=1)
|
|
203
|
+
* 4. Use git show to get diff (now parent is available for comparison)
|
|
200
204
|
*
|
|
201
205
|
* Used by:
|
|
202
206
|
* - All CI environments for push/commit context (GitHub, GitLab, Bitbucket, Vercel)
|
|
@@ -210,13 +214,31 @@ async function getCommitDiff(repoRoot, sha = 'HEAD') {
|
|
|
210
214
|
// Fetch parent commit on-demand to ensure git show can generate a proper diff
|
|
211
215
|
// This works regardless of CI checkout depth settings (depth=1 or depth=2)
|
|
212
216
|
// If parent is already available, fetch is fast/no-op; if not, we fetch it
|
|
213
|
-
// Get parent SHA
|
|
217
|
+
// Get parent SHA using plumbing command (git cat-file) instead of porcelain (git show)
|
|
218
|
+
// Plumbing commands ignore .git/shallow boundaries and show the actual parent SHA
|
|
219
|
+
// Porcelain commands (git show) respect shallow boundaries and hide parents in shallow clones
|
|
220
|
+
// This is critical for CI environments that use shallow clones (depth=1)
|
|
214
221
|
let parentSha;
|
|
215
222
|
try {
|
|
216
|
-
|
|
223
|
+
// Use git cat-file -p to read raw commit object (plumbing command)
|
|
224
|
+
// This ignores shallow boundaries and shows the actual parent SHA
|
|
225
|
+
const commitObject = (0, child_process_1.execSync)(`git cat-file -p ${sha}`, {
|
|
217
226
|
encoding: 'utf-8',
|
|
218
227
|
cwd: repoRoot
|
|
219
|
-
})
|
|
228
|
+
});
|
|
229
|
+
// Parse commit object to find first parent line
|
|
230
|
+
// Standard commits have one parent; merge commits have multiple parents
|
|
231
|
+
// We use the first parent (standard for diffing against previous state of branch)
|
|
232
|
+
const lines = commitObject.split('\n');
|
|
233
|
+
const parentLine = lines.find(line => line.startsWith('parent '));
|
|
234
|
+
if (!parentLine) {
|
|
235
|
+
throw new Error(`Commit ${sha} has no parent (it might be the root commit of the repository)`);
|
|
236
|
+
}
|
|
237
|
+
// Extract SHA from "parent <sha>" line
|
|
238
|
+
parentSha = parentLine.split(' ')[1].trim();
|
|
239
|
+
if (!parentSha || parentSha.length !== 40) {
|
|
240
|
+
throw new Error(`Invalid parent SHA format: "${parentSha}"`);
|
|
241
|
+
}
|
|
220
242
|
}
|
|
221
243
|
catch (error) {
|
|
222
244
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -224,7 +246,7 @@ async function getCommitDiff(repoRoot, sha = 'HEAD') {
|
|
|
224
246
|
`This is required to generate a proper diff. ` +
|
|
225
247
|
`Error: ${errorMessage}`);
|
|
226
248
|
}
|
|
227
|
-
// Fetch parent commit
|
|
249
|
+
// Fetch parent commit (root commits have no parent, so this won't execute for them)
|
|
228
250
|
if (parentSha && parentSha.length === 40) {
|
|
229
251
|
try {
|
|
230
252
|
// Fetch just this one commit (depth=1 is fine, we only need the parent)
|