Do not require a changelog file for PR created by Dependabot.

This commit is contained in:
Benoit Marty 2022-07-29 15:18:04 +02:00
parent c41f0dd0cf
commit d60695806f
1 changed files with 25 additions and 15 deletions

View File

@ -8,6 +8,8 @@ const {danger, warn} = require('danger')
// warn(JSON.stringify(danger)) // warn(JSON.stringify(danger))
const pr = danger.github.pr const pr = danger.github.pr
// User who has created the PR.
const user = pr.user.login
const modified = danger.git.modified_files const modified = danger.git.modified_files
const created = danger.git.created_files const created = danger.git.created_files
let editedFiles = [...modified, ...created] let editedFiles = [...modified, ...created]
@ -23,6 +25,13 @@ if (editedFiles.length > 50) {
} }
// Request a changelog for each PR // Request a changelog for each PR
const changelogAllowList = [
"dependabot[bot]",
]
let requiresChangelog = !changelogAllowList.includes(user)
if (requiresChangelog) {
let changelogFiles = editedFiles.filter(file => file.startsWith("changelog.d/")) let changelogFiles = editedFiles.filter(file => file.startsWith("changelog.d/"))
if (changelogFiles.length == 0) { if (changelogFiles.length == 0) {
@ -40,6 +49,7 @@ if (changelogFiles.length == 0) {
fail("Invalid extension for changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)") fail("Invalid extension for changelog. See instructions [here](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog)")
} }
} }
}
// Check for a sign-off // Check for a sign-off
const signOff = "Signed-off-by:" const signOff = "Signed-off-by:"
@ -66,7 +76,7 @@ const allowList = [
"yostyle", "yostyle",
] ]
let requiresSignOff = !allowList.includes(pr.user.login) let requiresSignOff = !allowList.includes(user)
if (requiresSignOff) { if (requiresSignOff) {
let hasPRBodySignOff = pr.body.includes(signOff) let hasPRBodySignOff = pr.body.includes(signOff)