This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Chore/remove redundant boxes #405
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ import { NextResponse } from "next/server"; | |
import getAllServices from "../../../../utils/actions/getAllServices"; | ||
import randomText from "../../../../utils/actions/markdownHelpers/randomText"; | ||
import createTeamAndMatchUser from "../../../../utils/db/teams/createTeamAndMatchUser"; | ||
import sendUninstall from "../../../../utils/sendgrid/sendUninstall"; | ||
|
||
|
||
|
||
const app = new App({ | ||
appId: process.env.GITHUB_APP_ID!, | ||
|
@@ -41,11 +44,11 @@ export async function POST(request: Request) { | |
try { | ||
// Verify and parse the webhook event | ||
const eventName = headers["x-github-event"]; | ||
|
||
let actionName = req.action; | ||
if ( | ||
req.action === "opened" || | ||
req.action === "reopened" || | ||
req.action === "synchronize" | ||
actionName === "opened" || | ||
actionName === "reopened" || | ||
actionName === "synchronize" | ||
) { | ||
const { missingParams } = validateParams(req, [ | ||
"pull_request", | ||
|
@@ -65,6 +68,12 @@ export async function POST(request: Request) { | |
|
||
const octokit = await app.getInstallationOctokit(installationId); | ||
|
||
if (pull_request.user.type === "Bot") { | ||
return new Response("We don't comment on bot PRs", { | ||
status: 400 | ||
}); | ||
} | ||
|
||
let octoCommitList = await octokit.request( | ||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", | ||
{ | ||
|
@@ -337,7 +346,7 @@ export async function POST(request: Request) { | |
|
||
const count = await addActionCount({ owner }); | ||
|
||
textToWrite += `### WatermelonAI Summary \n`; | ||
textToWrite += `### Watermelon AI Summary \n`; | ||
let businessLogicSummary; | ||
if (AISummary) { | ||
businessLogicSummary = await getOpenAISummary({ | ||
|
@@ -413,48 +422,55 @@ export async function POST(request: Request) { | |
repoName: repo, | ||
}); | ||
textToWrite += randomText(); | ||
|
||
// Detect console.logs and its equivalent in other languages | ||
await detectConsoleLogs({ | ||
prTitle: title, | ||
businessLogicSummary, | ||
repo, | ||
owner, | ||
issue_number: number, | ||
installationId, | ||
reqUrl: request.url, | ||
reqEmail: req.email, | ||
}); | ||
|
||
// Make Watermelon Review the PR's business logic here by comparing the title with the AI-generated summary | ||
await labelPullRequest({ | ||
prTitle: title, | ||
businessLogicSummary, | ||
repo, | ||
owner, | ||
issue_number: number, | ||
installationId, | ||
reqUrl: request.url, | ||
reqEmail: req.email, | ||
Promise.all([ | ||
// Detect console.logs and its equivalent in other languages | ||
detectConsoleLogs({ | ||
prTitle: title, | ||
businessLogicSummary, | ||
repo, | ||
owner, | ||
issue_number: number, | ||
installationId, | ||
reqUrl: request.url, | ||
reqEmail: req.email, | ||
}), | ||
// Make Watermelon Review the PR's business logic here by comparing the title with the AI-generated summary | ||
labelPullRequest({ | ||
prTitle: title, | ||
businessLogicSummary, | ||
repo, | ||
owner, | ||
issue_number: number, | ||
installationId, | ||
reqUrl: request.url, | ||
reqEmail: req.email, | ||
}), | ||
addActionLog({ | ||
randomWords, | ||
github, | ||
jira, | ||
slack, | ||
notion, | ||
linear, | ||
asana, | ||
textToWrite, | ||
businessLogicSummary, | ||
owner, | ||
repo, | ||
number, | ||
payload: req, | ||
count, | ||
watermelon_user, | ||
}), | ||
]).catch((error) => { | ||
failedPosthogTracking({ | ||
url: request.url, | ||
error: error.message, | ||
email: req.email, | ||
}); | ||
return console.error("posting comment error", error); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR contains console logs. Please review or remove them. |
||
|
||
await addActionLog({ | ||
randomWords, | ||
github, | ||
jira, | ||
slack, | ||
notion, | ||
linear, | ||
asana, | ||
textToWrite, | ||
businessLogicSummary, | ||
owner, | ||
repo, | ||
number, | ||
payload: req, | ||
count, | ||
watermelon_user, | ||
}); | ||
// Fetch all comments on the PR | ||
const comments = await octokit.request( | ||
"GET /repos/{owner}/{repo}/issues/{issue_number}/comments?sort=created&direction=desc", | ||
|
@@ -469,7 +485,9 @@ export async function POST(request: Request) { | |
); | ||
// Find our bot's comment | ||
let botComment = comments.data.find((comment) => { | ||
return comment?.user?.login.includes("watermelon-context"); | ||
return comment?.user?.login.includes( | ||
"watermelon-copilot-for-code-review" | ||
); | ||
}); | ||
if (botComment?.id) { | ||
// Update the existing comment | ||
|
@@ -502,7 +520,7 @@ export async function POST(request: Request) { | |
repo, | ||
owner, | ||
number, | ||
action: req.action, | ||
action: actionName, | ||
textToWrite, | ||
}, | ||
}); | ||
|
@@ -535,7 +553,7 @@ export async function POST(request: Request) { | |
|
||
// Find our bot's comment | ||
let botComment = comments.data.find((comment) => { | ||
return comment?.user?.login.includes("watermelon-context"); | ||
return comment?.user?.login.includes("watermelon-copilot-for-code-review"); | ||
}); | ||
|
||
// Update the existing comment | ||
|
@@ -557,15 +575,15 @@ export async function POST(request: Request) { | |
repo, | ||
owner, | ||
number, | ||
action: req.action, | ||
action: actionName, | ||
textToWrite, | ||
}, | ||
}); | ||
return NextResponse.json({ | ||
message: "success", | ||
textToWrite, | ||
}); | ||
} else if (req.action === "created" || req.action === "edited") { | ||
} else if (actionName === "created" || actionName === "edited") { | ||
console.log("comment keys", Object.keys(req)); | ||
const { missingParams } = validateParams(req, [ | ||
"installation", | ||
|
@@ -585,7 +603,7 @@ export async function POST(request: Request) { | |
const userLogin = comment.user.login; | ||
let botComment = comment.body; | ||
if ( | ||
userLogin === "watermelon-context[bot]" && | ||
userLogin === "watermelon-copilot-for-code-review[bot]" && | ||
botComment.includes("WatermelonAI Summary") | ||
) { | ||
// extract the business logic summary, it's always the first paragraph under the title | ||
|
@@ -623,11 +641,13 @@ export async function POST(request: Request) { | |
repo, | ||
owner, | ||
number, | ||
action: req.action, | ||
action: actionName, | ||
businessLogicSummary, | ||
}, | ||
}); | ||
} | ||
} else if (actionName === "deleted") { | ||
sendUninstall({ emails: [req.sender.email] }); | ||
} | ||
return NextResponse.json({ | ||
message: "wat", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { redirect } from 'next/navigation'; | ||
export default async function GHApp({ params }) { | ||
redirect('https://github.com/marketplace/watermelon-context'); | ||
redirect('https://github.com/marketplace/watermelon-copilot-for-code-review'); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains console logs. Please review or remove them.