Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Chore/remove redundant boxes #405

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
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"
15 changes: 0 additions & 15 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
“Commons Clause” License Condition v1.0

The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.

Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.

For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.

Software: [Watermelon]

License: [Apache 2.0 License]

Licensor: [Watermelon Tools, Inc.]


Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Watermelon's GitHub application allows teams to contextualize pull requests with

## Installation

You can install Watermelon's GitHub Application [directly from the marketplace](https://github.com/marketplace/watermelon-context).
You can install Watermelon's GitHub Application [directly from the marketplace](https://github.com/marketplace/watermelon-copilot-for-code-review).

## Contributing

Expand Down
9 changes: 0 additions & 9 deletions app/(loggedIn)/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ async function loading({}) {
<>
<>
<LoginGrid userEmail={userEmail} data={fakeData} />
<a href="https://github.com/apps/watermelon-context" target="_blank">
<div className="Box d-flex flex-items-center flex-justify-start m-3 p-2">
<img className="avatar avatar-8" src="/logos/watermelon.svg" />
<div className="p-2">
<h2>Try our GitHub App</h2>
<p>Context on each Pr</p>
</div>
</div>
</a>
<div
style={{
display: "grid",
Expand Down
77 changes: 1 addition & 76 deletions app/(loggedIn)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,85 +17,10 @@ async function HomePage({}) {
console.error(e);
return null;
});
const comingSoon = [
"IntelliJ",
"Android Studio",
"AppCode",
"Aqua",
"CLion",
"DataGrip",
"DataSpell",
"GoLand",
"MPS",
"PhpStorm",
"PyCharm",
"Rider",
"RubyMine",
"RustRover",
"WebStorm",
];

return (
<div>
{data && <LoginGrid userEmail={userEmail} data={data} />}
{userEmail && (
<div className="Box" style={{ height: "100%" }}>
<div className="Subhead px-3 pt-2">
<h2 className="Subhead-heading d-flex flex-items-center flex-justify-start">
<img className="avatar avatar-4" src="/logos/vscode.svg" />
<span>IDEs</span>
</h2>
</div>

<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(350px, 1fr))",
}}
>
<div className="pl-3 pr-3 pt-1 pb-3" style={{ flex: 1 }}>
<DownloadExtension
name="VSCode"
email={userEmail}
urlStart="vscode"
accessToken={userName}
/>
</div>

<div className="pl-3 pr-3 pt-1 pb-3" style={{ flex: 1 }}>
<DownloadExtension
name="VSCode Insiders"
urlStart="vscode-insiders"
email={userEmail}
accessToken={userName}
/>
</div>
<div className="pl-3 pr-3 pt-1 pb-3" style={{ flex: 1 }}>
<DownloadExtension
name="VSCodium"
urlStart="vscodium"
email={userEmail}
accessToken={userName}
/>
</div>
{comingSoon.map((name) => (
<a href="https://plugins.jetbrains.com/plugin/22720-watermelon-context">
<div className="p-3">
<div className="Box d-flex flex-items-center flex-justify-start p-2">
<img
className="avatar avatar-8"
src={`/logos/${name.toLowerCase()}.svg`}
/>
<div className="p-2">
<h2>{name}</h2>
<p>Download now</p>
</div>
</div>
</div>
</a>
))}
</div>
</div>
)}
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/(loggedIn)/team/sendInviteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function sendInviteForm({ teamName, userEmail }) {
<input
className="form-control "
type="email"
placeholder={`Teammate@${teamName?.name?.toLowerCase()}.com`}
placeholder={`Teammate@${teamName?.toLowerCase()}.com`}
aria-label="Teammate email"
/>
<button className="btn mx-2" type="submit" disabled={buttonDisabled}>
Expand Down
2 changes: 1 addition & 1 deletion app/(notLogged)/auth/verify/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function verify() {
</div>

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.

</div>

<a href="https://github.com/apps/watermelon-context" target="_blank">
<a href="https://github.com/apps/watermelon-copilot-for-code-review" target="_blank">
<div
className="Box d-flex flex-items-center flex-justify-center flex-column p-4 p-4 m-2"
style={{ maxWidth: "80ch" }}
Expand Down
124 changes: 72 additions & 52 deletions app/api/actions/github/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!,
Expand All @@ -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",
Expand All @@ -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",
{
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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);
});

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.


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",
Expand All @@ -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
Expand Down Expand Up @@ -502,7 +520,7 @@ export async function POST(request: Request) {
repo,
owner,
number,
action: req.action,
action: actionName,
textToWrite,
},
});
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/github-app/page.ts
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');
}
Loading