Home / Function/ summarizePackageCommits() — react Function Reference

summarizePackageCommits() — react Function Reference

Architecture documentation for the summarizePackageCommits() function in summaries.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  349b50fc_02df_e8e0_07c9_00b7984d8884["summarizePackageCommits()"]
  b5cf948c_d822_859d_c0f5_1e2c15545976["summaries.js"]
  349b50fc_02df_e8e0_07c9_00b7984d8884 -->|defined in| b5cf948c_d822_859d_c0f5_1e2c15545976
  7bd2c11f_b31e_f5c6_c40c_2af3e7471d4b["summarizePackages()"]
  7bd2c11f_b31e_f5c6_c40c_2af3e7471d4b -->|calls| 349b50fc_02df_e8e0_07c9_00b7984d8884
  ec5480b9_fa97_0f38_9e96_df41ded354f1["readChangelogSnippet()"]
  349b50fc_02df_e8e0_07c9_00b7984d8884 -->|calls| ec5480b9_fa97_0f38_9e96_df41ded354f1
  83a28a7e_bdfb_f0e7_e489_6618e9037da1["runSummarizer()"]
  349b50fc_02df_e8e0_07c9_00b7984d8884 -->|calls| 83a28a7e_bdfb_f0e7_e489_6618e9037da1
  e95d16c8_09ef_153a_9500_0afd4d1b9cac["parseSummariesResponse()"]
  349b50fc_02df_e8e0_07c9_00b7984d8884 -->|calls| e95d16c8_09ef_153a_9500_0afd4d1b9cac
  14eaac0e_edc0_329c_b841_354da5deefcc["sanitizeSummary()"]
  349b50fc_02df_e8e0_07c9_00b7984d8884 -->|calls| 14eaac0e_edc0_329c_b841_354da5deefcc
  style 349b50fc_02df_e8e0_07c9_00b7984d8884 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/tasks/generate-changelog/summaries.js lines 94–213

async function summarizePackageCommits({
  summarizer,
  spec,
  commits,
  packageTargets,
  allPackageSpecs,
  log,
}) {
  const summaries = new Map();
  if (commits.length === 0) {
    return {packageName: spec.name, summaries};
  }

  const rootStyle = readChangelogSnippet('root');
  const hooksStyle = readChangelogSnippet('eslint-plugin-react-hooks');
  const targetList = allPackageSpecs.map(
    targetSpec =>
      `${targetSpec.name}@${targetSpec.displayVersion || targetSpec.version}`
  );
  const payload = commits.map(commit => {
    const packages = Array.from(commit.packages || []).sort();
    const usesHooksStyle = (commit.packages || new Set()).has(
      'eslint-plugin-react-hooks'
    );
    const packagesWithVersions = packages.map(pkgName => {
      const targetSpec = packageTargets.get(pkgName);
      if (!targetSpec) {
        return pkgName;
      }
      return `${pkgName}@${targetSpec.displayVersion || targetSpec.version}`;
    });
    return {
      sha: commit.sha,
      packages,
      packagesWithVersions,
      style: usesHooksStyle ? 'eslint-plugin-react-hooks' : 'root',
      subject: commit.subject,
      body: commit.body || '',
    };
  });

  const promptParts = [
    `You are preparing changelog summaries for ${spec.name} ${
      spec.displayVersion || spec.version
    }.`,
    'The broader release includes:',
    ...targetList.map(line => `- ${line}`),
    '',
    'For each commit payload, write a single concise sentence without a leading bullet.',
    'Match the tone and formatting of the provided style samples. Do not mention commit hashes.',
    'Return a JSON array where each element has the shape `{ "sha": "<sha>", "summary": "<text>" }`.',
    'The JSON must contain one entry per commit in the same order they are provided.',
    'Use `"root"` style unless the payload specifies `"eslint-plugin-react-hooks"`, in which case use that style sample.',
    '',
    '--- STYLE: root ---',
    rootStyle,
    '--- END STYLE ---',
    '',
    '--- STYLE: eslint-plugin-react-hooks ---',
    hooksStyle,
    '--- END STYLE ---',
    '',
    `Commits affecting ${spec.name}:`,
  ];

  payload.forEach((item, index) => {
    promptParts.push(
      `Commit ${index + 1}:`,
      `sha: ${item.sha}`,
      `style: ${item.style}`,
      `packages: ${item.packagesWithVersions.join(', ') || 'none'}`,
      `subject: ${item.subject}`,
      'body:',
      item.body || '(empty)',
      ''
    );
  });
  promptParts.push('Return ONLY the JSON array.', '');

  const prompt = promptParts.join('\n');
  log(

Domain

Subdomains

Frequently Asked Questions

What does summarizePackageCommits() do?
summarizePackageCommits() is a function in the react codebase, defined in scripts/tasks/generate-changelog/summaries.js.
Where is summarizePackageCommits() defined?
summarizePackageCommits() is defined in scripts/tasks/generate-changelog/summaries.js at line 94.
What does summarizePackageCommits() call?
summarizePackageCommits() calls 4 function(s): parseSummariesResponse, readChangelogSnippet, runSummarizer, sanitizeSummary.
What calls summarizePackageCommits()?
summarizePackageCommits() is called by 1 function(s): summarizePackages.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free