mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-08 03:08:13 +00:00
fix(analyze): address Copilot review — ESM import, CLI option, .gitignore guard
- Replace require(" fs\) with ESM-compatible top-level import (statSync)
- Register --no-git option in Commander CLI definition
- Use hasGitDir() instead of isGitRepo() for .gitignore update guard
to match the PR intent (filesystem check vs git CLI invocation)
This commit is contained in:
parent
4dffd81b12
commit
f0f384aab7
3 changed files with 6 additions and 3 deletions
|
|
@ -328,8 +328,10 @@ export const analyzeCommand = async (
|
|||
};
|
||||
await saveMeta(storagePath, meta);
|
||||
await registerRepo(repoPath, meta);
|
||||
// Only attempt to update .gitignore when a git repository is present
|
||||
if (repoHasGit) {
|
||||
// Only attempt to update .gitignore when a .git directory is present.
|
||||
// Use hasGitDir (filesystem check) rather than isGitRepo (shells out to git)
|
||||
// so we skip correctly for --no-git folders even if git CLI is available.
|
||||
if (hasGitDir(repoPath)) {
|
||||
await addToGitignore(repoPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ program
|
|||
.option('-f, --force', 'Force full re-index even if up to date')
|
||||
.option('--embeddings', 'Enable embedding generation for semantic search (off by default)')
|
||||
.option('--skills', 'Generate repo-specific skill files from detected communities')
|
||||
.option('--no-git', 'Index a folder without requiring a .git directory')
|
||||
.option('-v, --verbose', 'Enable verbose ingestion warnings (default: false)')
|
||||
.addHelpText('after', '\nEnvironment variables:\n GITNEXUS_NO_GITIGNORE=1 Skip .gitignore parsing (still reads .gitnexusignore)')
|
||||
.action(createLazyAction(() => import('./analyze.js'), 'analyzeCommand'));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { execSync } from 'child_process';
|
||||
import { statSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
// Git utilities for repository detection, commit tracking, and diff analysis
|
||||
|
|
@ -47,7 +48,6 @@ export const getGitRoot = (fromPath: string): string | null => {
|
|||
*/
|
||||
export const hasGitDir = (dirPath: string): boolean => {
|
||||
try {
|
||||
const { statSync } = require('fs') as typeof import('fs');
|
||||
statSync(path.join(dirPath, '.git'));
|
||||
return true;
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue