Skip to content

Commit

Permalink
Correctly compare dates for PR retrieval; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed May 24, 2021
1 parent ff0ddae commit 0b306da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/src/Gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 3 additions & 5 deletions test/Gren.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

Expand Down

0 comments on commit 0b306da

Please sign in to comment.