| 229 | // } |
| 230 | |
| 231 | function convertStringToLog(logString) { |
| 232 | let log = []; |
| 233 | for (let line of logString) { |
| 234 | if (line === "" || line === "\r" || line === "\n") continue; |
| 235 | // console.log(line); |
| 236 | |
| 237 | //split line based on the format: d2739e4f193137db4d86450f0d50b3489d75c106 d2739e4f1 style: adjusted testConfig and modesNotice. |
| 238 | //use regex to split |
| 239 | // const [_, hash, shortHash, fullMessage] = line.split( |
| 240 | // /(\w{40}) (\w{9,10}) (.*)/ |
| 241 | // ); |
| 242 | |
| 243 | const [hash, shortHash, title, body] = line |
| 244 | .split(logDelimiter) |
| 245 | .map((s) => s.trim()); |
| 246 | |
| 247 | // console.log({ |
| 248 | // hash, |
| 249 | // shortHash, |
| 250 | // title, |
| 251 | // body, |
| 252 | // }); |
| 253 | |
| 254 | //split message using regex based on fix(language): spelling mistakes in Nepali wordlist and quotes (sapradhan) (#4528) |
| 255 | //scope is optional, username is optional, pr number is optional |
| 256 | const [_, type, scope, message, username, pr] = title.split( |
| 257 | /^(\w+)(?:\(([^)]+)\))?:\s+(.+?)(?:\s*\((@[^)]+)\))?(?:\s+\((#[^)]+)\))?$/, |
| 258 | ); |
| 259 | |
| 260 | const usernames = username ? username.split(", ") : []; |
| 261 | const prs = pr ? pr.split(", ") : []; |
| 262 | |
| 263 | if (type && message) { |
| 264 | log.push({ |
| 265 | hashes: [ |
| 266 | { |
| 267 | short: shortHash, |
| 268 | full: hash, |
| 269 | }, |
| 270 | ], |
| 271 | type, |
| 272 | scope, |
| 273 | message, |
| 274 | usernames: usernames ?? [], |
| 275 | prs: prs ?? [], |
| 276 | body: body ?? "", |
| 277 | }); |
| 278 | } else { |
| 279 | // console.log({ hash, shortHash, title, body }); |
| 280 | // console.warn("skipping line due to invalid format: " + line); |
| 281 | } |
| 282 | } |
| 283 | return log; |
| 284 | } |
| 285 | |
| 286 | const header = |
| 287 | "Thank you to all the contributors who made this release possible!"; |