Browse Source

Fix: scripts changelog cli per page set to 100

GitHub pagination was limiting the result to 30 issues.
This fix makes the changelog script return up to 100
issues. Will have to add a loop to fetch more once we
merge more than 100 PR's that should be added to the
changelog.

Also, fixes a bug where issues that were not included
in the milestone were being returned.
Daniel Lee 6 năm trước cách đây
mục cha
commit
3146500de5
1 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 5 4
      scripts/cli/tasks/changelog.ts

+ 5 - 4
scripts/cli/tasks/changelog.ts

@@ -1,6 +1,6 @@
+import axios from 'axios';
 import _ from 'lodash';
 import { Task, TaskRunner } from './task';
-import axios from 'axios';
 
 const githubGrafanaUrl = 'https://github.com/grafana/grafana';
 
@@ -9,7 +9,7 @@ interface ChangelogOptions {
 }
 
 const changelogTaskRunner: TaskRunner<ChangelogOptions> = async ({ milestone }) => {
-  let client = axios.create({
+  const client = axios.create({
     baseURL: 'https://api.github.com/repos/grafana/grafana',
     timeout: 10000,
   });
@@ -17,6 +17,7 @@ const changelogTaskRunner: TaskRunner<ChangelogOptions> = async ({ milestone })
   const res = await client.get('/issues', {
     params: {
       state: 'closed',
+      per_page: 100,
       labels: 'add to changelog',
     },
   });
@@ -42,7 +43,7 @@ const changelogTaskRunner: TaskRunner<ChangelogOptions> = async ({ milestone })
     'title'
   );
 
-  const notBugs = _.sortBy(res.data.filter(item => !bugs.find(bug => bug === item)), 'title');
+  const notBugs = _.sortBy(issues.filter(item => !bugs.find(bug => bug === item)), 'title');
 
   let markdown = '### Features / Enhancements\n';
 
@@ -60,7 +61,7 @@ const changelogTaskRunner: TaskRunner<ChangelogOptions> = async ({ milestone })
 
 function getMarkdownLineForIssue(item: any) {
   let markdown = '';
-  let title = item.title.replace(/^([^:]*)/, (match, g1) => {
+  const title = item.title.replace(/^([^:]*)/, (match, g1) => {
     return `**${g1}**`;
   });