Skip to content

Commit

Permalink
Test uncommon PR content and minor fixes
Browse files Browse the repository at this point in the history
- Test an uncommon PR patch, as seen in [1]
- Fix engine value in package.json to Node 12
- Fix husky configuration multiline value
- Remove unnused `require` in main.js
- Remove old debug logging from main.js
- Fix typos

--
1. simple-icons/simple-icons#3112
  • Loading branch information
ericcornelissen committed May 27, 2020
1 parent 9dcb689 commit d48a716
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .huskyrc.yml
@@ -1,5 +1,5 @@
hooks:
pre-commit: |
pre-commit: >
git stash -q --keep-index &&
npm run build &&
git add lib/index.js &&
Expand Down
19 changes: 19 additions & 0 deletions __mocks__/@actions/github.js
Expand Up @@ -81,6 +81,11 @@ const PRs = [ // https://developer.github.com/v3/pulls/#list-pull-requests
merged_at: "2011-01-26T19:01:12Z",
base: { ref: "develop" }
},
{ // PR that changes the data file but no metadata
number: 511,
merged_at: "2011-01-26T19:01:12Z",
base: { ref: "develop" }
},


{ // Previous release
Expand Down Expand Up @@ -319,6 +324,20 @@ const prFiles = {
"title": "Simple Icons",
"hex": "555555",`
}
],
"511": [
{
filename: SI_DATA_FILE,
status: STATUS_MODIFIED,
patch: `"title": "Razer",
"hex": "00FF00",
"source": "https://en.wikipedia.org/wiki/File:Razer_snake_logo.svg"
+ },...
- },
{
"title": "React",
"hex": "61DAFB",`
}
]
};

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,6 +25,6 @@
"husky": "^4.2.5"
},
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
}
}
12 changes: 2 additions & 10 deletions src/main.js
@@ -1,6 +1,5 @@
const core = require("@actions/core");
const github = require("@actions/github");
const { Octokit } = require("@octokit/rest");
const moment = require("moment");
const semverInc = require("semver/functions/inc");

Expand Down Expand Up @@ -261,7 +260,7 @@ async function getFilesSinceLastRelease(client) {
}

if (isReleasePr(pr)) {
// Pevious release, earlier changes definitely already released
// Previous release, earlier changes definitely already released
core.info(`found previous release, PR #${pr.number}`);
return files.filter(file => moment(file.merged_at).isAfter(pr.merged_at));
}
Expand Down Expand Up @@ -343,10 +342,6 @@ function getChangesFromFile(file, id) {
}

function filterDuplicates(newIcons, updatedIcons, removedIcons) {
console.log("====================================================");
console.log("Before filtering", newIcons, updatedIcons, removedIcons);
console.log("====================================================");

// An added icon was update before the release
let removeFromUpdated = [];
for (let newIcon of newIcons) {
Expand Down Expand Up @@ -401,10 +396,6 @@ function filterDuplicates(newIcons, updatedIcons, removedIcons) {
}
updatedIcons = updatedIcons.filter(a => !removeFromUpdated.some(b => a.id === b.id));

console.log("====================================================");
console.log("After filtering", newIcons, updatedIcons, removedIcons);
console.log("====================================================");

return [newIcons, updatedIcons, removedIcons];
}

Expand Down Expand Up @@ -495,6 +486,7 @@ async function createReleasePr(client, title, body) {
core.debug(title);
core.debug("\nPR body:");
core.debug(body);

const prNumber = await createPullRequest(client, title, body, BRANCH_DEVELOP, BRANCH_MASTER);
core.debug(`\nNew release PR is: ${prNumber}`);

Expand Down

0 comments on commit d48a716

Please sign in to comment.