Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minor bugs #508

Merged
merged 4 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGELOG
=====================================

| February 25, 2021 : fix: minor bugs `#508 <https://github.com/mergeability/mergeable/pull/508>`_
| February 25, 2021 : fix: Correct use of cache env
| February 18, 2021 : fix: Scheduler support `#499 <https://github.com/mergeability/mergeable/issues/499>`_
| February 12, 2021 : feat: Implemented redis as a dependency to the helm-chart
Expand Down
6 changes: 3 additions & 3 deletions lib/actions/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Comment extends Action {
async handleError (context, payload) {
const issueNumber = this.getPayload(context).number

await this.removeErrorComments(context)
await this.removeErrorComments(context, this)

return createComment(
context,
Expand All @@ -71,13 +71,13 @@ class Comment extends Action {
)
}

async removeErrorComments (context) {
async removeErrorComments (context, actionObj) {
if (_.isUndefined(this.getPayload(context))) return
const issueNumber = this.getPayload(context).number
const oldComments = await fetchCommentsByMergeable(context, issueNumber)
const errorComments = oldComments.filter(comment => comment.body.toLowerCase().includes('error'))

return deleteOldComments(context, errorComments)
return deleteOldComments(context, errorComments, actionObj)
}

// there is nothing to do
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/request_review.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const createRequestReview = async (context, number, reviewers, actionObj) => {
action_name: actionObj.name
}

actionObj.log.error(JSON.stringify(errorLog))
actionObj.log.info(JSON.stringify(errorLog))
Copy link
Member

Choose a reason for hiding this comment

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

What is the reasoning for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

because we are using info for other known errors as well

}
return res
}
Expand Down
6 changes: 5 additions & 1 deletion lib/interceptors/checkReRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ class CheckReRun extends Interceptor {
if (!(context.eventName === 'check_run' && context.payload.action === 'rerequested')) return context

let checkRun = context.payload.check_run
if (!checkRun) return context
// some checkRun doesn't have output field, skip if output field is not present
if (!checkRun || !checkRun.output) return context

let meta = MetaData.deserialize(checkRun.output.text)
if (this.possibleInjection(context, checkRun, meta)) return context

// sometimes the checkRun.pull_requests is empty, in those cases, just skip
if (checkRun.pull_requests.length === 0) return context

let pr = await context.octokit.pulls.get(context.repo({pull_number: checkRun.pull_requests[0].number}))
context.payload.action = meta.action
context.eventName = meta.eventName
Expand Down