MCPcopy Create free account
hub / github.com/47ng/nuqs / parseCommits

Function parseCommits

packages/scripts/lib/commit-graph.ts:500–532  ·  view source on GitHub ↗
(records: CommitRecord[])

Source from the content-addressed store, hash-verified

498// under squash-merge, where one PR == one commit); a recurrence with a divergent
499// `type`/`breaking` keeps the first entry but warns so the conflict is visible.
500function parseCommits(records: CommitRecord[]): ParsedCommit[] {
501 const parsed: ParsedCommit[] = []
502 const seen = new Map<number, ParsedCommit>()
503 for (const { sha, author, message } of records) {
504 const firstLine = message.split('\n')[0] ?? ''
505 const prNumber = extractPRNumber(firstLine)
506 const { type, breaking, description } = parseCommit(message)
507 const commit: ParsedCommit = {
508 sha,
509 author,
510 prNumber,
511 type,
512 breaking,
513 description
514 }
515 if (prNumber === null) {
516 parsed.push(commit)
517 continue
518 }
519 const existing = seen.get(prNumber)
520 if (existing === undefined) {
521 seen.set(prNumber, commit)
522 parsed.push(commit)
523 } else if (existing.type !== type || existing.breaking !== breaking) {
524 // A `(#N)` recurring with a divergent type/breaking (rare under
525 // squash-merge). Keep the first-seen (authoritative) entry, but warn.
526 console.warn(
527 `commit-graph: PR #${prNumber} recurs with a conflicting type/breaking; keeping the first-seen one.`
528 )
529 }
530 }
531 return parsed
532}
533
534// Project a fetched PR into a PR-sourced change: `type`/`breaking` from the
535// squash commit (via `byNumber`), `description` from the PR title as prose (its

Callers 1

parseRangeFunction · 0.85

Calls 3

parseCommitFunction · 0.90
extractPRNumberFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected