diff --git a/lib/rules/line-length.js b/lib/rules/line-length.js index 2d5b60c..3a568a9 100644 --- a/lib/rules/line-length.js +++ b/lib/rules/line-length.js @@ -29,10 +29,14 @@ export default { let failed = false for (let i = 0; i < parsed.body.length; i++) { const line = parsed.body[i] + // Skip quoted lines, e.g. for original commit messages of V8 backports. if (line.startsWith(' ')) { continue } // Skip lines with URLs. if (/https?:\/\//.test(line)) { continue } + // Skip co-authorship. + if (/^co-authored-by:/i.test(line)) { continue } + if (line.length > len) { failed = true context.report({ diff --git a/test/rules/line-length.js b/test/rules/line-length.js index d8bda5f..1de6420 100644 --- a/test/rules/line-length.js +++ b/test/rules/line-length.js @@ -129,5 +129,60 @@ https://${'very-'.repeat(80)}-long-url.org/ tt.end() }) + t.test('Co-author lines', (tt) => { + const sha = 'f1496de5a7d5474e39eafaafe6f79befe5883a5b' + const author = { + name: 'Jacob Smith', + email: '3012099+JakobJingleheimer@users.noreply.github.com', + date: '2025-12-22T09:40:42Z' + } + + const v = new Validator() + const overlongMessage = `fixup!: apply case-insensitive suggestion + Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>` + const bad = new Commit({ + sha, + author, + message: overlongMessage + }, v) + + bad.report = (opts) => { + tt.pass('called report') + tt.equal(opts.id, 'line-length', 'id') + tt.equal(opts.string, overlongMessage.split('\n')[1], 'string') + tt.equal(opts.level, 'fail', 'level') + } + + Rule.validate(bad, { + options: { + length: 72 + } + }) + + const good = new Commit({ + sha, + author, + message: [ + 'fixup!: apply case-insensitive suggestion', + 'Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>' + ].join('\n') + }, v) + + good.report = (opts) => { + tt.pass('called report') + tt.equal(opts.id, 'line-length', 'id') + tt.equal(opts.string, '', 'string') + tt.equal(opts.level, 'pass', 'level') + } + + Rule.validate(good, { + options: { + length: 72 + } + }) + + tt.end() + }) + t.end() })