Skip to content

Commit

Permalink
fix: revert logging to the same schema as it used to be (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed May 9, 2023
1 parent f8ea664 commit 81f5d4d
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 115 deletions.
7 changes: 1 addition & 6 deletions api/github/webhooks.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
const { createNodeMiddleware, createProbot } = require("probot");
const pino = require("pino");

const app = require("../../app");

module.exports = createNodeMiddleware(app, {
probot: createProbot({
overrides: {
log: pino(),
},
}),
probot: createProbot(),
webhooksPath: "/api/github/webhooks",
});
65 changes: 40 additions & 25 deletions lib/process-issue-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,8 @@ async function processIssueComment({ context, commentReply }) {

const { action, contributors } = parseComment(commentBody);

const log = context.log.child({
action,
contributors,
account: repo.owner.id,
accountType: repo.owner.type.toLowerCase(),
accountLogin: repo.owner.login,
createdBy: createdBy.id,
createdByLogin: createdBy.login,
createdByType: createdBy.type.toLowerCase(),
repository: repo.id,
private: repo.private,
success: false,
});

if (action !== "add") {
log.info(`Unknown action "${action}"`);
context.log.info(`Unknown action "${action}"`);
commentReply.reply(`I could not determine your intention.`);
commentReply.reply(
`Basic usage: @all-contributors please add @someone for code, doc and infra`
Expand All @@ -40,15 +26,44 @@ async function processIssueComment({ context, commentReply }) {
}

for (var contributor in contributors) {
const who = contributor
const contributions = contributors[who]
const who = contributor;
const contributions = contributors[who];
const branchName = `all-contributors/add-${toSafeGitReferenceName(who)}`;

await triggerActionAdd(context, commentReply, log, who, contributions, branchName)
const log = context.log.child({
who,
action,
contributions,
account: repo.owner.id,
accountType: repo.owner.type.toLowerCase(),
accountLogin: repo.owner.login,
createdBy: createdBy.id,
createdByLogin: createdBy.login,
createdByType: createdBy.type.toLowerCase(),
repository: repo.id,
private: repo.private,
success: false,
});

await triggerActionAdd(
context,
commentReply,
log,
who,
contributions,
branchName
);
}
}

async function triggerActionAdd(context, commentReply, log, who, contributions, branchName) {
async function triggerActionAdd(
context,
commentReply,
log,
who,
contributions,
branchName
) {
if (contributions.length === 0) {
log.info("No contributions");
commentReply.reply(
Expand Down Expand Up @@ -77,13 +92,13 @@ async function triggerActionAdd(context, commentReply, log, who, contributions,
branchName,
});

if(!pullCreated) {
if (!pullCreated) {
log.info(
{
pullCreated,
success: true,
},
`${who} already have ${contributions.join(", ")}`
{
pullCreated,
success: true,
},
`${who} already have ${contributions.join(", ")}`
);
return;
}
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"got": ">=11.8.5",
"jest": "^27.3.1",
"nock": "^13.1.4",
"pino": "^6.11.2",
"prettier": "^2.4.1",
"smee-client": "^1.2.3",
"vercel": "^28.15.3"
Expand Down
Loading

1 comment on commit 81f5d4d

@vercel
Copy link

@vercel vercel bot commented on 81f5d4d May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.