mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-29 23:37:41 +00:00
* fix(cli): let trace run on --from-uid/--to-uid without positional names (#4124) 'trace <from> <to>' made commander exit 1 before the handler could run, even though traceCommand and the backend both treat each name as optional when the matching *_uid flag is present. Declare the positionals as [from] [to] — matching context/impact/query — and keep the per-endpoint usage validation in traceCommand, so 'gitnexus trace A' (missing 'to', no --to-uid) still fails with usage. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(cli): cover UID-only trace in a separate process Incorporates the corresponding part of #4186. Co-authored-by: SomilDaswani <119527365+SomilDaswani@users.noreply.github.com> --------- Co-authored-by: Karan Kapur <karank2512@users.noreply.github.com> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Gergő Magyar <gergomagyar@icloud.com> Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com> Co-authored-by: SomilDaswani <119527365+SomilDaswani@users.noreply.github.com>
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
/**
|
|
* `gitnexus trace` must accept two exact UIDs without positional names, while
|
|
* still rejecting an endpoint that has neither a name nor a UID. The dispatcher
|
|
* used to declare `trace <from> <to>`, so Commander exited before traceCommand
|
|
* could run.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { spawnSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { CLI_SPAWN_PREFIX } from '../../helpers/cli-entry.js';
|
|
|
|
function runTrace(args: string[]) {
|
|
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'gitnexus-trace-uid-'));
|
|
try {
|
|
const r = spawnSync(process.execPath, [...CLI_SPAWN_PREFIX, 'trace', ...args], {
|
|
env: { ...process.env, GITNEXUS_HOME: home, NODE_OPTIONS: '', CI: '1' },
|
|
encoding: 'utf8',
|
|
timeout: 60_000,
|
|
});
|
|
return { code: r.status, stderr: r.stderr ?? '' };
|
|
} finally {
|
|
fs.rmSync(home, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
describe('CLI trace — UID-only endpoints', () => {
|
|
it('does not fail argument parsing when both UIDs are supplied', () => {
|
|
const { stderr } = runTrace([
|
|
'--from-uid',
|
|
'Function:a.ts:alpha',
|
|
'--to-uid',
|
|
'Function:a.ts:gamma',
|
|
]);
|
|
expect(stderr).not.toContain('missing required argument');
|
|
// Parsing succeeded, so the handler ran and hit the empty registry.
|
|
expect(stderr).toContain('No indexed repositories found');
|
|
}, 90_000);
|
|
|
|
it('still prints usage when an endpoint has neither a name nor a UID', () => {
|
|
const { code, stderr } = runTrace(['--from-uid', 'Function:a.ts:alpha']);
|
|
expect(code).toBe(1);
|
|
expect(stderr).toContain('Usage: gitnexus trace');
|
|
}, 90_000);
|
|
});
|