FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

rules: accept "deps: V8" as the subsystem for revert commits by RaisinTen · Pull Request #102 · nodejs/core-validate-commit · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 10 additions & 5 deletions lib/rules/title-format.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ module.exports = {
recommended: true
},
validate: (context, rule) => {
const isRevertCommit = /^Revert ".*"$/.test(context.title)
const revertPrefixLength = 'Revert "'.length
const titleWithoutRevertPrefix = isRevertCommit
? context.title.substr(revertPrefixLength,
context.title.length - revertPrefixLength - 1) : context.title
let pass = true
if (/[.?!]$/.test(context.title)) {
if (/[.?!]$/.test(titleWithoutRevertPrefix)) {
context.report({
id: id,
message: 'Do not use punctuation at end of title.',
Expand All @@ -23,7 +28,7 @@ module.exports = {
}

{
const result = /^([^:]+:)[^ ]/.exec(context.title)
const result = /^([^:]+:)[^ ]/.exec(titleWithoutRevertPrefix)
if (result) {
context.report({
id: id,
Expand All @@ -38,7 +43,7 @@ module.exports = {
}

{
const result = /\s\s/.exec(context.title)
const result = /\s\s/.exec(titleWithoutRevertPrefix)
if (result) {
context.report({
id: id,
Expand All @@ -52,9 +57,9 @@ module.exports = {
}
}

const isV8 = context.title.startsWith('deps: V8:')
const isV8 = titleWithoutRevertPrefix.startsWith('deps: V8:')
if (!isV8) {
const result = /^([^:]+?): [A-Z]/.exec(context.title)
const result = /^([^:]+?): [A-Z]/.exec(titleWithoutRevertPrefix)
if (result) {
context.report({
id: id,
Expand Down
29 changes: 29 additions & 0 deletions test/validator.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ Date: Sun May 1 21:10:21 2022 +0530
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
`

const str12 = `commit cbb404503c9df13aaeb3dd8b345cb3f34c8c07e4
Author: Michaël Zasso <targos@protonmail.com>
Date: Sat Oct 22 10:22:43 2022 +0200

Revert "deps: V8: forward declaration of \`Rtl*FunctionTable\`"

This reverts commit 01bc8e6fd81314e76c7fb0d09e5310f609e48bee.
`

test('Validator - misc', (t) => {
const v = new Validator()

Expand Down Expand Up @@ -294,6 +303,26 @@ test('Validator - real commits', (t) => {
})
})

t.test('accept deps: V8 as the subsystem for revert commits', (tt) => {
const v = new Validator({
'validate-metadata': false
})
v.lint(str12)
v.on('commit', (data) => {
const c = data.commit.toJSON()
tt.equal(c.sha, 'cbb404503c9df13aaeb3dd8b345cb3f34c8c07e4', 'sha')
tt.equal(c.date, 'Sat Oct 22 10:22:43 2022 +0200', 'date')
tt.deepEqual(c.subsystems, ['deps'], 'subsystems')
tt.equal(c.revert, true, 'revert')
const msgs = data.messages
const filtered = msgs.filter((item) => {
return item.level === 'fail'
})
tt.equal(filtered.length, 0, 'messages.length')
tt.end()
})
})

t.test('invalid pr-url, missing subsystem', (tt) => {
const v = new Validator()
v.lint(str4)
Expand Down

Back | FazBrowse Home | New Git URL