difit 3.1.11 → 3.1.12

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.
@@ -59,6 +59,11 @@ vi.mock('./git-diff.js', () => {
59
59
  isEmpty: false,
60
60
  });
61
61
  getBlobContent = vi.fn().mockResolvedValue(Buffer.from('mock image data'));
62
+ getGeneratedStatus = vi.fn().mockResolvedValue({
63
+ isGenerated: true,
64
+ source: 'content',
65
+ });
66
+ clearResolvedCommitCache = vi.fn();
62
67
  getRevisionOptions = vi.fn().mockResolvedValue({
63
68
  branches: [{ name: 'main', current: true }],
64
69
  commits: [{ hash: 'abc1234', shortHash: 'abc1234', message: 'Test commit' }],
@@ -250,6 +255,29 @@ describe('Server Integration Tests', () => {
250
255
  expect(response.ok).toBe(true);
251
256
  expect(data).toHaveProperty('ignoreWhitespace', true);
252
257
  });
258
+ it('GET /api/generated-status/* returns generated status', async () => {
259
+ const response = await fetch(`http://localhost:${port}/api/generated-status/src/query.ts?ref=HEAD`);
260
+ const data = (await response.json());
261
+ expect(response.ok).toBe(true);
262
+ expect(data).toEqual({
263
+ path: 'src/query.ts',
264
+ ref: 'HEAD',
265
+ isGenerated: true,
266
+ source: 'content',
267
+ });
268
+ });
269
+ it('GET /api/generated-status/* rejects paths outside repository', async () => {
270
+ const response = await fetch(`http://localhost:${port}/api/generated-status/%2Ftmp%2Foutside.txt?ref=HEAD`);
271
+ const data = (await response.json());
272
+ expect(response.status).toBe(400);
273
+ expect(data).toHaveProperty('error', 'File path outside repository');
274
+ });
275
+ it('GET /api/generated-status/* rejects parent traversal paths', async () => {
276
+ const response = await fetch(`http://localhost:${port}/api/generated-status/..%2Foutside.txt?ref=HEAD`);
277
+ const data = (await response.json());
278
+ expect(response.status).toBe(400);
279
+ expect(data).toHaveProperty('error', 'File path outside repository');
280
+ });
253
281
  it('POST /api/comments accepts comment data', async () => {
254
282
  const comments = [{ file: 'test.js', line: 10, body: 'This is a test comment' }];
255
283
  const response = await fetch(`http://localhost:${port}/api/comments`, {
@@ -345,6 +373,17 @@ describe('Server Integration Tests', () => {
345
373
  expect(response.ok).toBe(true);
346
374
  expect(data).toHaveProperty('openInEditorAvailable', false);
347
375
  });
376
+ it('GET /api/generated-status/* returns 400 for stdin diff', async () => {
377
+ const stdinServer = await startServer({
378
+ stdinDiff: 'diff --git a/stdin-test.js b/stdin-test.js',
379
+ preferredPort: 9036,
380
+ });
381
+ servers.push(stdinServer.server);
382
+ const response = await fetch(`http://localhost:${stdinServer.port}/api/generated-status/stdin-test.js?ref=HEAD`);
383
+ const data = (await response.json());
384
+ expect(response.status).toBe(400);
385
+ expect(data).toHaveProperty('error', 'Generated status is not available for stdin diff');
386
+ });
348
387
  });
349
388
  describe('Static file serving', () => {
350
389
  let originalNodeEnv;
@@ -48,6 +48,12 @@ export interface DiffResponse {
48
48
  clearComments?: boolean;
49
49
  repositoryId?: string;
50
50
  }
51
+ export interface GeneratedStatusResponse {
52
+ path: string;
53
+ ref: string;
54
+ isGenerated: boolean;
55
+ source: 'path' | 'content';
56
+ }
51
57
  export type LineNumber = number | [number, number];
52
58
  export interface Comment {
53
59
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "difit",
3
- "version": "3.1.11",
3
+ "version": "3.1.12",
4
4
  "description": "A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view",
5
5
  "keywords": [
6
6
  "cli",
@@ -40,6 +40,7 @@
40
40
  "dev:cli": "tsc --project tsconfig.cli.json && NODE_ENV=development node dist/cli/index.js",
41
41
  "build": "tsc -b && vite build",
42
42
  "build:cli": "tsc --project tsconfig.cli.json",
43
+ "package:vscode": "pnpm -C packages/vscode run package",
43
44
  "start": "pnpm run build && node dist/cli/index.js",
44
45
  "check": "oxlint . --type-aware --type-check --deny-warnings --report-unused-disable-directives",
45
46
  "check:fix": "oxlint . --type-aware --type-check --deny-warnings --report-unused-disable-directives --fix",