-
Notifications
You must be signed in to change notification settings - Fork 1
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
action.cjs: include filtered diff in the watermark #221
Conversation
6998aeb
to
cce9970
Compare
cce9970
to
4cfffb6
Compare
4cfffb6
to
563bc16
Compare
563bc16
to
752a7cf
Compare
anthropic debug - [puLL-Merge] - brave/pull-merge@221 Diffdiff --git action.cjs action.cjs
index 4d88768..ca3271b 100644
--- action.cjs
+++ action.cjs
@@ -106,11 +106,14 @@ module.exports = async ({ github, context, inputs, actionPath }) => {
: `openai debug - ${watermark}`
}
+ const header = '<details><summary>Diff</summary>\n\n```diff\n\n' + filteredPatch + '\n\n```\n\n</details>'
+
await submitReview({
owner: options.owner,
repo: options.repo,
prnum: options.prnum,
watermark,
+ header,
explainPatch: explainPatchCb,
debounceTime: options.debounce_time,
debug,
diff --git src/submitReview.js src/submitReview.js
index 169bcbf..da46407 100644
--- src/submitReview.js
+++ src/submitReview.js
@@ -16,6 +16,7 @@ export default async function submitReview ({
owner, repo, prnum, watermark, debounceTime,
explainPatch = async () => 'no explanation provided<!-- Generated by STUB -->',
githubToken = null,
+ header = '',
github = null,
debug = false
}) {
@@ -81,7 +82,7 @@ export default async function submitReview ({
owner,
repo,
issue_number: prnum,
- body: watermark + '\n\n' + patchExplained
+ body: watermark + '\n\n' + header + '\n\n' + patchExplained
})
}
}
diff --git src/subtleSubmitReview.js src/subtleSubmitReview.js
index 4bd0bc5..2912323 100644
--- src/subtleSubmitReview.js
+++ src/subtleSubmitReview.js
@@ -21,6 +21,7 @@ export default async function subtleSubmitReview ({
explainPatch = async () => 'no explanation provided<!-- Generated by STUB -->',
githubToken = null,
github = null,
+ header = '',
debug = false
}) {
if (!github && githubToken) {
@@ -63,7 +64,7 @@ export default async function subtleSubmitReview ({
const end = escapeRegex('<!-- Generated by ') + '\\w+' + escapeRegex(' --></details>')
const re = new RegExp(`${begin}.*${end}`, 's')
- const newExplaination = '<details><summary>AI Review</summary>' + '\n\n' + watermark + '\n\n' + await explainPatch() + '</details>'
+ const newExplaination = '<details><summary>AI Review</summary>' + '\n\n' + watermark + '\n\n' + header + '\n\n' + await explainPatch() + '</details>'
// fetch the message twice, to decrease the chances of race condition, but still debounce
const msg = (await github.graphql(query, variables)).repository.pullRequest
DescriptionThis PR enhances the pull request review process by adding a diff header to the review comments. It modifies the action.cjs, submitReview.js, and subtleSubmitReview.js files to include a collapsible diff section in the review comment, improving the context and readability of the AI-generated reviews. ChangesChanges
This sequence diagram illustrates the flow of the review process with the new header inclusion. The action creates the header, which is then passed to both submitReview and subtleSubmitReview functions. These functions incorporate the header into their respective review comments before submitting them to the GitHub API.```mermaid
|
444ca9a
to
f0cc5a8
Compare
openai debug - [puLL-Merge] - brave/pull-merge@221 DescriptionThis Pull Request (PR) enhances the repository's action by introducing an option to include diffs in the review comments. The main motivation is to provide detailed information within the review, potentially improving code collaboration and review efficiency. The new Possible IssuesNone identified. Security HotspotsNone identified. ChangesChanges
sequenceDiagram
participant User
participant GitHub
participant Action
participant ReviewFunction
User->>GitHub: Create Pull Request or Push Changes
GitHub->>Action: Trigger GitHub Action
Action->>Action: Parse options, including include_diff
Action->>ReviewFunction: Call submitReview with parsed options
Action->>ReviewFunction: Call subtleSubmitReview with parsed options
ReviewFunction->>Action: Generate Review Body with Diff if include_diff == true
Action->>GitHub: Submit Review
GitHub->>User: Display Review with optional Diff
|
bedrock debug - [puLL-Merge] - brave/pull-merge@221 DescriptionThis PR enhances the pull request review functionality by adding an option to include the diff in the generated text and making several related adjustments. The main motivation appears to be improving the visibility and context of the changes being reviewed. ChangesChanges
sequenceDiagram
participant User
participant GitHub
participant ActionRunner
participant ReviewBot
User->>GitHub: Create/Update Pull Request
GitHub->>ActionRunner: Trigger Action
ActionRunner->>ReviewBot: Run review process
ReviewBot->>GitHub: Fetch PR details
ReviewBot->>ReviewBot: Generate explanation
alt include_diff is true or actor is bot
ReviewBot->>ReviewBot: Include diff in header
end
ReviewBot->>GitHub: Submit review comment
GitHub->>User: Display review comment
Possible Issues
Security HotspotsNone identified. |
No description provided.