{"record":{"id":"e2fa46061ec89b91","repo":"facebook/docusaurus","slug":"failed-to-retrieve-the-git-history-for-file-fil-e2fa46","errorCode":null,"errorMessage":"Failed to retrieve the git history for file \"${file}\" with unexpected output: ${output}","messagePattern":"Failed to retrieve the git history for file \"(.+?)\" with unexpected output: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-utils/src/vcs/gitUtils.ts","lineNumber":190,"sourceCode":"\n  // We only parse the output line starting with our \"RESULT:\" prefix\n  // See why https://github.com/facebook/docusaurus/pull/10022\n  const regex = includeAuthor\n    ? /(?:^|\\n)RESULT:(?<timestamp>\\d+),(?<author>.+)(?:$|\\n)/\n    : /(?:^|\\n)RESULT:(?<timestamp>\\d+)(?:$|\\n)/;\n\n  const output = result.stdout.trim();\n\n  if (!output) {\n    throw new FileNotTrackedError(\n      `Failed to retrieve the git history for file \"${file}\" because the file is not tracked by git.`,\n    );\n  }\n\n  const match = output.match(regex);\n\n  if (!match) {\n    throw new Error(\n      `Failed to retrieve the git history for file \"${file}\" with unexpected output: ${output}`,\n    );\n  }\n\n  const timestampInSeconds = Number(match.groups!.timestamp);\n  const timestamp = timestampInSeconds * 1_000;\n  const date = new Date(timestamp);\n\n  if (includeAuthor) {\n    return {date, timestamp, author: match.groups!.author!};\n  }\n  return {date, timestamp};\n}\n\nlet showedGitRequirementError = false;\nlet showedFileNotTrackedError = false;\n\ntype GitCommitInfo = {timestamp: number; author: string};","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-utils/src/vcs/gitUtils.ts#L172-L208","documentation":"Thrown by getFileCommitDate() when git log produced non-empty output but the RESULT: prefix regex failed to match it. The function uses a 'RESULT:%ct' (or 'RESULT:%ct,%an' with includeAuthor) format and parses with a regex; a match failure indicates git emitted something unexpected — most likely a GPG signature line, a hook output, or a git version/format quirk that breaks the assumed output shape.","triggerScenarios":"git log ran with the RESULT: format string but its stdout, after trimming, does not contain a line matching the expected RESULT:<digits>(,<author>) pattern. The code already passes -c log.showSignature=false to suppress GPG signature noise; a mismatch suggests that suppression did not take effect, the git version misbehaves, or a custom log format hook interfered.","commonSituations":"Commits signed with GPG where showSignature=false did not suppress the signature (older git versions, or a config override). A global git hook (e.g. a pager or formatter) that mutates log output. A git version with a formatting bug. Concurrent git invocations interleaving output (rare thanks to GitCommandQueue).","solutions":["Inspect the output echoed in the error message — compare it to the expected 'RESULT:<timestamp>(,<author>)' shape.","If GPG signature lines are present, ensure no global config forces `log.showSignature=true`; the per-call -c flag should override but a faulty gitrc can interfere.","Disable any git pager or hook that could alter log output (unset GIT_PAGER, run with --no-pager for diagnostics).","If the issue persists, reproduce manually with `git -c log.showSignature=false log --format=RESULT:%ct --max-count=1 -- <file>` to see exactly what git emits."],"exampleFix":"# before — global config forces signed log output\ngit config --global log.showSignature true\n\n# after\ngit config --global --unset log.showSignature\n# or scope the override per-repo after the build","handlingStrategy":"try-catch","validationCode":"import { execaSync } from 'execa';\nimport path from 'path';\n\nfunction gitLogOutputMatchesExpected(file: string): boolean {\n  const r = execaSync('git', ['-c', 'log.showSignature=false', 'log', '--format=RESULT:%ct', '--max-count=1', '--', path.basename(file)], { cwd: path.dirname(file) });\n  return /(?:^|\\n)RESULT:\\d+/.test(r.stdout.trim());\n}\n\nif (!gitLogOutputMatchesExpected(file)) {\n  throw new Error('git log output shape is unexpected; check for GPG signatures or hooks.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getFileCommitDate(file, { age: 'newest' });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('with unexpected output')) {\n    // inspect err message: the raw git output is appended; check for signature lines or hook noise\n  }\n  throw err;\n}","preventionTips":["Do not force `log.showSignature=true` globally; Docusaurus passes -c log.showSignature=false per call but a faulty gitrc can interfere.","Avoid global git hooks or pagers that mutate log output.","Reproduce the exact git invocation from the error to see what git emits when this fires."],"tags":["git","parsing","gpg","internal"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}