MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / categorizeCommits

Function categorizeCommits

utils/scripts/generate-release-notes.js:98–148  ·  view source on GitHub ↗
(commits, { mergeOnly, importantOnly })

Source from the content-addressed store, hash-verified

96}
97
98function categorizeCommits(commits, { mergeOnly, importantOnly }) {
99 const sections = {
100 feat: [],
101 fix: [],
102 perf: [],
103 refactor: [],
104 docs: [],
105 chore: [],
106 test: [],
107 add: [],
108 revert: [],
109 update: [],
110 other: [],
111 };
112
113 for (const c of commits) {
114 const msg = c.commit.message.split("\n")[0];
115 const isMerge =
116 msg.startsWith("Merge pull request") || msg.startsWith("Merge branch");
117
118 if (mergeOnly && !isMerge) continue;
119
120 const type =
121 Object.keys(sections).find((k) => {
122 const lowerMsg = msg.toLowerCase();
123 return (
124 lowerMsg.startsWith(`${k}:`) ||
125 lowerMsg.startsWith(`${k} `) ||
126 lowerMsg.startsWith(`${k}: `) ||
127 lowerMsg.startsWith(`${k}(`) // handles e.g. 'feat(plugin-api): ...'
128 );
129 }) || "other";
130
131 if (
132 importantOnly &&
133 !["feat", "fix", "refactor", "perf", "add", "revert", "update"].includes(
134 type,
135 )
136 )
137 continue;
138
139 const author = c.author?.login
140 ? `[${c.author.login}](https://github.com/${c.author.login})`
141 : "unknown";
142
143 const entry = `- ${msg} (${c.sha.slice(0, 7)}) by ${author}`;
144 sections[type].push(entry);
145 }
146
147 return sections;
148}
149
150const emojis = {
151 feat: flags.plain ? "" : "✨ ",

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected