{"record":{"id":"533539262ee0c730","repo":"abhigyanpatwari/GitNexus","slug":"gitnexus-self-commit-skipping-file-s-with-unco","errorCode":null,"errorMessage":"gitnexus: --self-commit skipping file(s) with uncommitted changes from before this analyze run","messagePattern":"gitnexus: --self-commit skipping file\\(s\\) with uncommitted changes from before this analyze run","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/storage/git.ts","lineNumber":187,"sourceCode":" * above uses `--porcelain`. If `git commit` fails after `git add` already\n * staged the safe files (e.g. missing git identity), the staged files are\n * reset back to unstaged so the user's index isn't silently left mutated.\n * No-ops silently (never throws) when: none of the candidate files exist or\n * are safe, none changed, or any git step fails. Must never fail the\n * surrounding `analyze` run. See #2639.\n */\nexport const selfCommitContextFiles = (\n  repoPath: string,\n  candidateFiles: string[],\n  preRunSafety: Map<string, boolean>,\n): void => {\n  const existing = candidateFiles.filter((name) => existsSync(path.join(repoPath, name)));\n  if (existing.length === 0) return;\n\n  const safe = existing.filter((name) => preRunSafety.get(name) === true);\n  const skippedDirty = existing.filter((name) => preRunSafety.get(name) !== true);\n  if (skippedDirty.length > 0) {\n    logger.warn(\n      { files: skippedDirty },\n      'gitnexus: --self-commit skipping file(s) with uncommitted changes from before this analyze run',\n    );\n  }\n  if (safe.length === 0) return;\n\n  try {\n    const status = execFileSync('git', ['status', '--porcelain', '--', ...safe], {\n      cwd: repoPath,\n      stdio: ['ignore', 'pipe', 'ignore'],\n      windowsHide: true,\n      encoding: 'utf8',\n    });\n    if (status.trim().length === 0) return; // nothing to commit\n  } catch {\n    return; // git failed (not a repo, git missing, etc.) — nothing to do\n  }\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/storage/git.ts#L169-L205","documentation":"With --self-commit, GitNexus auto-commits its generated context files — but only those recorded as clean in the preRunSafety map captured before the analyze run started. Files that already had uncommitted changes are excluded from the auto-commit and listed in this warning, so the tool never sweeps user work-in-progress into an automatic commit.","triggerScenarios":"Running gitnexus analyze --self-commit in a repo where one of the candidate context files (those that exist on disk) was already modified before the run: exactly those files are skipped, the still-clean ones are committed as usual.","commonSituations":"Hand-edited generated context files; a previous analyze killed before its self-commit could finish; leftover merge-conflict edits in generated files.","solutions":["Review and commit or stash your own changes to those files, then re-run analyze --self-commit","Or commit them manually: the warning only means the tool declined to include them in its commit","Stop hand-editing files managed by --self-commit; keep overrides in files the tool does not claim"],"exampleFix":"# before: file dirty from before the run -> skipped with warning\necho '# my note' >> .gitnexus/context.md && gitnexus analyze --self-commit\n\n# after: commit your edit first, then let the tool own subsequent changes\ngit add .gitnexus/context.md && git commit -m 'chore: context note' && gitnexus analyze --self-commit","handlingStrategy":"validation","validationCode":"import { execFileSync } from 'node:child_process';\n// Mirror the tool's own precondition before relying on --self-commit:\nconst dirty = candidateFiles.filter((f) =>\n  execFileSync('git', ['status', '--porcelain', '--', f], {\n    cwd: repoPath, stdio: ['ignore', 'pipe', 'ignore'],\n  }).toString() !== '',\n);\nif (dirty.length) {\n  // --self-commit will skip exactly these files; commit or stash them first.\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit or stash before running analyze --self-commit","Keep hand edits out of tool-managed files","Read the files array in the warning to see exactly what was skipped"],"tags":["git","self-commit","analyze","working-tree","safety"],"backgroundTag":"dirty-working-tree","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}