Skip to content
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
10 changes: 10 additions & 0 deletions .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CB Secret PR Scan

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
SecretScanning:
uses: chargebee/cb-secrets-scanner/.github/workflows/cb-secret-scan.yml@main
secrets: inherit
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.4
hooks:
- id: gitleaks
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ on:
types:
- opened
- closed
- synchronize # See https://mychargebee.atlassian.net/browse/TECHINT-498
- synchronize

branches:
- master
Expand All @@ -50,7 +50,7 @@ jobs:
prStatusChange:
runs-on: ubuntu-latest
steps:
- name: Install Node # See https://github.com/chargebee/chargebee-app/pull/37468
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18.x
Expand Down
21 changes: 21 additions & 0 deletions apps/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ async function setLabels(context, issueNumber, labels) {
await context.octokit.issues.setLabels(context.repo({issue_number: issueNumber, labels: labels}))
}

async function resolveAllComments(context, prNumber) {
try {
const { data: comments } = await context.octokit.request(
'GET /repos/{owner}/{repo}/pulls/{pull_number}/comments',
context.repo({pull_number: prNumber})
)

for (const comment of comments) {
if (comment.user.login !== 'cursor[bot]') continue;
console.log("deleting comment : " + comment.id);
await context.octokit.request(
'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}',
context.repo({comment_id: comment.id})
);
}
} catch(err) {
console.error(err);
}
}

async function mergePr(context, pr, onMergeFailure) {
const maxRetries = 5
let i = 0
Expand Down Expand Up @@ -56,6 +76,7 @@ async function isMergeable (context, prNumber) {
const maxRetries = 5
let i = 0
while (i++ < maxRetries) {
await resolveAllComments(context, prNumber);
Copy link

Choose a reason for hiding this comment

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

Bug: Unnecessary API Calls in Merge Check Loop

Calling resolveAllComments inside the isMergeable retry loop causes it to repeatedly fetch and delete bot comments. This leads to unnecessary API calls (up to 5 times per check) and potential rate limiting, while also adding a side effect to a function meant for checking mergeability.

Fix in Cursor Fix in Web

const pr = await context.octokit.pulls.get(context.repo({pull_number: prNumber}))
console.log(`PR Details of ${prNumber}`)
console.log(JSON.stringify(pr.data, null, 2));
Expand Down
21 changes: 21 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ async function setLabels(context, issueNumber, labels) {
await context.octokit.issues.setLabels(context.repo({issue_number: issueNumber, labels: labels}))
}

async function resolveAllComments(context, prNumber) {
try {
const { data: comments } = await context.octokit.request(
'GET /repos/{owner}/{repo}/pulls/{pull_number}/comments',
context.repo({pull_number: prNumber})
)

for (const comment of comments) {
if (comment.user.login !== 'cursor[bot]') continue;
console.log("deleting comment : " + comment.id);
await context.octokit.request(
'DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}',
context.repo({comment_id: comment.id})
);
}
} catch(err) {
console.error(err);
}
}

async function mergePr(context, pr, onMergeFailure) {
const maxRetries = 5
let i = 0
Expand Down Expand Up @@ -85,6 +105,7 @@ async function isMergeable (context, prNumber) {
const maxRetries = 5
let i = 0
while (i++ < maxRetries) {
await resolveAllComments(context, prNumber);
const pr = await context.octokit.pulls.get(context.repo({pull_number: prNumber}))
console.log(`PR Details of ${prNumber}`)
console.log(JSON.stringify(pr.data, null, 2));
Expand Down