-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_issues.html
119 lines (102 loc) · 3.22 KB
/
export_issues.html
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<logbox id="log"></logbox>
<style>
p {
margin: 2px;
}
<STYLE MEDIA="print"> width = "200px"; </STYLE>
</style>
<script src="https://unpkg.com/marked@latest/marked.min.js"></script>
<script>
// Replace these with your own values
const owner = 'gpersoon';
const repo = 'issue-system';
const accessToken = ''; // Create a personal access token in your GitHub account settings
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/issues`;
function log(logstr) {
document.getElementById("log").innerHTML +=logstr+"\n";
}
async function fetchAllIssues() {
let issues = [];
let url = apiUrl;
while (url) {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `token ${accessToken}`,
'Accept': 'application/vnd.github.v3+json',
},
});
if (response.ok) {
const data = await response.json();
issues = issues.concat(data);
const linkHeader = response.headers.get('Link');
if (linkHeader) {
const links = linkHeader.split(',');
const nextLink = links.find(link => link.includes('rel="next"'));
if (nextLink) {
url = nextLink.match(/<([^>]*)>/)[1];
} else {
url = null;
}
} else {
url = null;
}
} else {
throw new Error(`Failed to fetch issues: ${response.status} - ${await response.text()}`);
}
}
return issues;
}
async function displayIssues() {
const issues = await fetchAllIssues();
const severities = ['Severity: High ','Severity: Medium','Severity: Low','Severity: Informational', 'Severity: Gas optimization']
const sevletter = ['H','M','L','I', 'G']
j=0
log(marked.parse(`## Summary of issues`))
for (const sev of severities) {
log(marked.parse(`### ${sev}`))
index=0
for (const item of issues) {
if (!item.labels[0]) continue
if (item.labels[0].name != sev) continue
index++
log(marked.parse(`${sevletter[j]}-${index} : ${(item.title)}`))
//log(marked.parse(item.body))
}
j++
}
j=0
log(marked.parse(`## Details of issues`))
for (const sev of severities) {
log(marked.parse(`### ${sev}`))
index=0
for (const item of issues) {
if (!item.labels[0]) continue
if (item.labels[0].name != sev) continue
index++
log(marked.parse(`### #${sevletter[j]}-${index} : ${(item.title)}`))
log(marked.parse(item.body))
}
j++
}
}
async function intro() {
let filePath='report/intro.md'
let url=`https://api.github.com/repos/${owner}/${repo}/contents/${filePath}`
console.log(url);
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `token ${accessToken}`,
'Accept': 'application/vnd.github.v3+json',
},
});
let a = await response.json()
console.log(a.content)
let b = atob(a.content); // Decode base64 content
console.log(b)
log(marked.parse(b));
await displayIssues();
}
intro();
</script>