From 0b306da3c19adeef4781a3042488f9b53462fe3a Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Mon, 24 May 2021 16:16:08 -0400 Subject: [PATCH] Correctly compare dates for PR retrieval; fix tests --- lib/src/Gren.js | 2 +- lib/src/_utils.js | 2 +- package.json | 1 + test/Gren.spec.js | 8 +++----- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/src/Gren.js b/lib/src/Gren.js index 7833b677..857c46ae 100644 --- a/lib/src/Gren.js +++ b/lib/src/Gren.js @@ -430,7 +430,7 @@ class Gren { const { headers: { link }, data: prs } = results; const totalPages = this._getLastPage(link); const filterPrs = prs.filter(pr => pr.merged_at); - if (prs.length > 0 && since < prs[prs.length - 1].updated_at && + if (prs.length > 0 && since < (new Date(prs[prs.length - 1].updated_at)) && totalPages && +page < totalPages) { return this._getMergedPullRequests(since, page + 1).then(prsResults => prsResults.concat(filterPrs)); } diff --git a/lib/src/_utils.js b/lib/src/_utils.js index dcbbf6c4..e368bf4f 100644 --- a/lib/src/_utils.js +++ b/lib/src/_utils.js @@ -160,7 +160,7 @@ function convertStringToArray(arrayLike) { * @return {string} */ function formatDate(date) { - return ('0' + date.getDate()).slice(-2) + '/' + ('0' + (date.getMonth() + 1)).slice(-2) + '/' + date.getFullYear(); + return ('0' + date.getUTCDate()).slice(-2) + '/' + ('0' + (date.getUTCMonth() + 1)).slice(-2) + '/' + date.getUTCFullYear(); } /** diff --git a/package.json b/package.json index 8b2956c2..0af84e3f 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Create a release from a tag and uses issues or commits to creating the release notes. It also can generate a CHANGELOG.md file based on the release notes (or generate a brand new).", "main": "./github-release-notes.js", "scripts": { + "build": "gulp build", "start": "node github-release-notes.js", "test": "./node_modules/.bin/nyc mocha --reporter=nyan --compilers=js:babel-register", "coverage": "nyc --reporter=lcov --reporter=text mocha --compilers=js:babel-register", diff --git a/test/Gren.spec.js b/test/Gren.spec.js index 18da7585..096c082b 100644 --- a/test/Gren.spec.js +++ b/test/Gren.spec.js @@ -220,12 +220,10 @@ describe('Gren', () => { 'Others:': ['closed'] }; - gren.options.groupPostProcessor = (groupContent) => { - return groupContent.replace(0, groupContent.indexOf(':\n') + 3); - } + gren.options.groupPostProcessor = (groupContent) => groupContent.replace(0, groupContent.indexOf(':\n') + 3); - assert.deepEqual(gren._groupBy(normal), [`Test:`], 'Passing one heading for one issue'); - assert.deepEqual(gren._groupBy(noLabel), [`Others:`], 'Group option is "label" with no labels'); + assert.deepEqual(gren._groupBy(normal), [`Test:\nIssue with one label and milestone`], 'Passing one heading for one issue'); + assert.deepEqual(gren._groupBy(noLabel), [`Others:\nIssue with no milestone and no labels`], 'Group option is "label" with no labels'); }); });