-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathcreate-github-issue.js
54 lines (42 loc) · 1.9 KB
/
create-github-issue.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
window.addEventListener('load', addGitHubIssueButton);
function addGitHubIssueButton() {
document.querySelector('#githubissue button').addEventListener('click', createGitHubIssue);
document.getElementById('githubissue').hidden = false;
}
function createGitHubIssue(event) {
event.preventDefault();
const value = document.getElementById('repository').value.trim();
const match = value.match(/github\.com\/(.*?)\/?$/);
const repo = match ? match[1] : value;
if (!repo.match(/^[^\s\/]+\/[^\s\/]+$/)) {
console.warn('Invalid repository name entered', value);
window.alert(`Invalid repository name: "${value}".\nExpected format: "owner/repo", e.g. "w3c/foobar".`);
return;
}
const title = encodeURIComponent('Seek wide review');
const body = encodeURIComponent(generateGitHubIssueBody());
window.open(`https://github.com/${repo}/issues/new?title=${title}&body=${body}`);
}
function generateGitHubIssueBody() {
const dl = document.querySelector('#how-to-get-horizontal-review ~ dl');
if (!dl) {
console.error('Could not find right anchor in "How to get horizontal review" section');
}
const bullets = [...dl.querySelectorAll('dt')].map(dt => {
const dd = dt.nextElementSibling;
if (dd.tagName !== 'DD') {
console.error('Could not find a DD tag after DT', dt);
return;
}
const subContents = [...dd.querySelectorAll('.step')].map(el => ` - [ ] ${el.innerHTML}`);
return ` - ${dt.textContent}\n${subContents.join('\n')}`;
});
return `This is a meta issue to track wide review steps for the specification.
See [How to do wide review](https://www.w3.org/guide/documentreview/#who-to-ask-for-wide-review) for details.
- [ ] the groups listed in the WG's charter, especially those who manage dependencies
- [ ] the groups jointly responsible for a particular document (if any).
- the horizontal groups:
${bullets.join('\n')}
- Other outreach (if applicable)
`;
}