forked from twbs/bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.issue-guidelines.js
85 lines (66 loc) · 2.88 KB
/
.issue-guidelines.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* ==========================================================
* issue-guidelines.js
* http://twitter.github.com/bootstrap/javascript.html#alerts
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
var assert = require('assert')
module.exports = {
'pull-requests': {
'should always be made against -wip branches': function (pull) {
assert.ok(/\-wip$/.test(pull.base.ref))
},
'should always be made from feature branches': function (pull) {
assert.notEqual(pull.head.ref, 'master')
},
'should always include a unit test if changing js files': function (pull) {
var hasJS = false
var hasTests = false
pull.files.forEach(function (file) {
if (/^js\/[^./]+.js/.test(file.filename)) hasJS = true
if (/^js\/tests\/unit\/[^.]+.js/.test(file.filename)) hasTests = true
})
assert.ok(!hasJS || hasJS && hasTests)
},
'after': function (pull) {
if (pull.reporter.stats.failures) {
pull.reportFailures(pull.close.bind(pull))
}
}
},
'issues': {
'before': function (issue) {
var plus = {}
var labels = issue.labels.map(function (label) { return label.name });
if (~labels.indexOf('popular')) return
issue.comments.forEach(function (comment) {
if (/\+1/.test(comment.body)) plus[comment.user.login] = true
})
if (Object.keys(plus).length > 5) {
issue.tag('popular')
issue.comment('Tagging this issue as popular, please stop commenting on this issue with +1. thanks!')
}
},
'should include a jsfiddle/jsbin illustrating the problem if tagged with js but not a feature': function (issue) {
var labels = issue.labels.map(function (label) { return label.name });
if (~labels.indexOf('js') && !~labels.indexOf('feature')) assert.ok(/(jsfiddle|jsbin)/.test(issue.body))
},
'after': function (issue) {
if (issue.reporter.stats.failures) {
issue.reportFailures(issue.close.bind(issue))
}
}
}
}