Merge pull request #179 from vector-im/michaelk/danger_check_github_org
Attempt to check org/group membership before danger complains about signoff.
This commit is contained in:
commit
c38020be34
1 changed files with 35 additions and 3 deletions
|
|
@ -86,9 +86,8 @@ const allowList = [
|
||||||
"yostyle",
|
"yostyle",
|
||||||
]
|
]
|
||||||
|
|
||||||
const requiresSignOff = !allowList.includes(user)
|
function signoff_needed(reason) {
|
||||||
|
message("Sign-off required, " + reason)
|
||||||
if (requiresSignOff) {
|
|
||||||
const hasPRBodySignOff = pr.body.includes(signOff)
|
const hasPRBodySignOff = pr.body.includes(signOff)
|
||||||
const hasCommitSignOff = danger.git.commits.every(commit => commit.message.includes(signOff))
|
const hasCommitSignOff = danger.git.commits.every(commit => commit.message.includes(signOff))
|
||||||
if (!hasPRBodySignOff && !hasCommitSignOff) {
|
if (!hasPRBodySignOff && !hasCommitSignOff) {
|
||||||
|
|
@ -96,6 +95,39 @@ if (requiresSignOff) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function signoff_unneeded(reason) {
|
||||||
|
message("Sign-off not required, " + reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Somewhat awkward phrasing, dangerfile is not in an async context.
|
||||||
|
if (allowList.includes(user)) {
|
||||||
|
signoff_unneeded("allow-list")
|
||||||
|
} else {
|
||||||
|
// github.api.rest.orgs.checkMembershipForUser({
|
||||||
|
// org: "vector-im",
|
||||||
|
// username: user,
|
||||||
|
// }).then((result) => {
|
||||||
|
github.api.rest.teams.getMembershipForUserInOrg({
|
||||||
|
org: "vector-im",
|
||||||
|
team_slug: "vector-core",
|
||||||
|
username: user,
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.status == 204 || result.status == 200) {
|
||||||
|
signoff_unneeded("team-member")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
signoff_needed("not-team-member")
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
if (error.response.status == 404) {
|
||||||
|
signoff_needed("not-team-member");
|
||||||
|
} else {
|
||||||
|
console.log(error); signoff_needed("error")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for screenshots on view changes
|
// Check for screenshots on view changes
|
||||||
const hasChangedViews = editedFiles.filter(file => file.includes("/layout")).length > 0
|
const hasChangedViews = editedFiles.filter(file => file.includes("/layout")).length > 0
|
||||||
if (hasChangedViews) {
|
if (hasChangedViews) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue