-
Notifications
You must be signed in to change notification settings - Fork 0
/
issues.js
51 lines (46 loc) · 1.26 KB
/
issues.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
const config = require('./config'),
octokit = require('@octokit/rest')({ headers: config.headers });
const removeExcludedLabels = (issues) => {
const lowerLabels = config.excludeLabels.map(label => label.toLowerCase())
return issues.filter(issue => !issue.labels.some(label => lowerLabels.includes(label.name.toLowerCase())))
};
async function issues() {
octokit.authenticate({
type: 'token',
token: config.token
});
data = {
owner: config.owner,
repo: config.repoName,
labels: config.labels,
state: 'all'
};
issues = []
try {
var response = await octokit.issues.listForRepo(data);
issues.push.apply(issues, response.data);
while (octokit.hasNextPage(response)) {
response = await octokit.getNextPage(response)
issues.push.apply(issues, response.data);
}
return removeExcludedLabels(issues);
} catch (err) {
console.error("An error occured getting issues" + err.stack);
};
}
function clearAssignee(owner, repo, issueIds, assignees) {
console.log(issueIds);
let data = {
owner: owner,
repo: repo,
assignees: assignees
};
issueIds.forEach(num => {
data.number = num;
octokit.issues.removeAssignees(data);
})
}
module.exports = {
issues: issues,
clearAssignee: clearAssignee
};