MCPcopy
hub / github.com/laurent22/joplin / formatCommitMessage

Function formatCommitMessage

packages/tools/git-changelog.js:127–272  ·  view source on GitHub ↗
(commit, msg, author, options)

Source from the content-addressed store, hash-verified

125}
126
127function formatCommitMessage(commit, msg, author, options) {
128 options = Object.assign({}, { publishFormat: 'full' }, options);
129
130 let output = '';
131
132 const splitted = msg.split(':');
133
134 let subModule = '';
135
136 const isPlatformPrefix = prefix => {
137 prefix = prefix.split(',').map(p => p.trim().toLowerCase());
138 for (const p of prefix) {
139 if (['android', 'mobile', 'ios', 'desktop', 'cli', 'clipper', 'all', 'api', 'plugins', 'server'].indexOf(p) >= 0) return true;
140 }
141 return false;
142 };
143
144 if (splitted.length) {
145 const platform = splitted[0].trim().toLowerCase();
146 if (platform === 'api') subModule = 'api';
147 if (platform === 'plugins') subModule = 'plugins';
148 if (isPlatformPrefix(platform)) {
149 splitted.splice(0, 1);
150 }
151
152 output = splitted.join(':');
153 }
154
155 output = output.split('\n')[0].trim();
156
157 const detectType = msg => {
158 msg = msg.trim().toLowerCase();
159
160 if (msg.indexOf('fix') === 0) return 'fixed';
161 if (msg.indexOf('add') === 0) return 'new';
162 if (msg.indexOf('change') === 0) return 'improved';
163 if (msg.indexOf('update') === 0) return 'improved';
164 if (msg.indexOf('improve') === 0) return 'improved';
165
166 return 'improved';
167 };
168
169 const parseCommitMessage = (msg, subModule) => {
170 const parts = msg.split(':');
171
172 if (parts.length === 1) {
173 return {
174 type: detectType(msg),
175 message: msg.trim(),
176 subModule: subModule,
177 };
178 }
179
180 let originalType = parts[0].trim();
181 let t = originalType.toLowerCase();
182
183 parts.splice(0, 1);
184 let message = parts.join(':').trim();

Callers 1

createChangeLogFunction · 0.85

Calls 5

isPlatformPrefixFunction · 0.85
parseCommitMessageFunction · 0.85
capitalizeFirstLetterFunction · 0.85
escapeHtmlFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected