MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / parseChangelog

Function parseChangelog

scripts/prepare-release.mjs:73–92  ·  view source on GitHub ↗

* Split the CHANGELOG into a header preface + an ordered list of * version blocks `{ header, body[] }`, preserving line content * verbatim so we can re-join without surprises.

(text)

Source from the content-addressed store, hash-verified

71 * verbatim so we can re-join without surprises.
72 */
73function parseChangelog(text) {
74 const lines = text.split('\n');
75 const versionHeaderRe = /^## \[([^\]]+)\](?:\s+-\s+(.+))?\s*$/;
76 const preface = [];
77 const blocks = []; // { header: string, name: string, body: string[] }
78 let cur = null;
79 for (const line of lines) {
80 const m = line.match(versionHeaderRe);
81 if (m) {
82 if (cur) blocks.push(cur);
83 cur = { header: line, name: m[1], date: m[2] ?? null, body: [] };
84 } else if (cur) {
85 cur.body.push(line);
86 } else {
87 preface.push(line);
88 }
89 }
90 if (cur) blocks.push(cur);
91 return { preface, blocks };
92}
93
94function joinChangelog({ preface, blocks }) {
95 const parts = [preface.join('\n')];

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected