-
Notifications
You must be signed in to change notification settings - Fork 133
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
upload annotations in github pull requests #501
Conversation
} | ||
} | ||
|
||
// https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#update-a-pull-request | ||
export async function githubUpsetPullRequest( | ||
script: PromptScript, | ||
info: GithubConnectionInfo, | ||
text: string, | ||
commentTag: string | ||
) { | ||
const { apiUrl, repository, issue } = info | ||
|
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.
The 'GITHUB_TOKEN' constant is being used as a secret key, but it should be using the 'token' from 'GithubConnectionInfo' which is already extracted from the environment.
generated by genaiscript pr-review-commit
const url = `${apiUrl}/repos/${repository}/issues/${issue}/comments` | ||
|
||
body = appendGeneratedComment(script, info, body) | ||
|
||
if (commentTag) { | ||
const tag = `<!-- genaiscript ${commentTag} -->` |
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.
The 'appendGeneratedComment' function is being called without checking if 'info.runUrl' is defined, which could lead to incorrect markdown formatting if 'info.runUrl' is undefined.
generated by genaiscript pr-review-commit
info: GithubConnectionInfo, | ||
body: string, | ||
commentTag?: string | ||
commentTag: string |
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.
The 'appendGeneratedComment' function is being called without checking if 'info.runUrl' is defined, which could lead to incorrect markdown formatting if 'info.runUrl' is undefined.
generated by genaiscript pr-review-commit
@@ -66,13 +83,13 @@ export async function githubUpsetPullRequest( | |||
const resGetJson = (await resGet.json()) as { body: string } | |||
let { body } = resGetJson | |||
if (!body) body = "" |
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.
The 'appendGeneratedComment' function is being called without checking if 'info.runUrl' is defined, which could lead to incorrect markdown formatting if 'info.runUrl' is undefined.
generated by genaiscript pr-review-commit
The pull request introduces several changes across multiple files in a TypeScript project. Here's a high-level review of the changes:
Overall, the changes seem to focus on enhancing the CLI tool's integration with GitHub, particularly around handling pull request reviews and comments. The refactoring and addition of new utility functions suggest an improvement in code quality and maintainability. Concerns:
Given the scope of the changes and assuming proper testing and configuration management practices are in place, the pull request looks good to me. LGTM (Looks Good To Me).
|
@@ -12,6 +14,9 @@ export interface GithubConnectionInfo { | |||
ref?: string | |||
sha?: string | |||
issue?: number | |||
runId?: string | |||
runUrl?: string | |||
commitSha?: string | |||
} | |||
|
|||
export function parseGHTokenFromEnv( |
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.
The parseGHTokenFromEnv
function has been updated to include runId
, runUrl
, and commitSha
but the corresponding interface GithubConnectionInfo
has not been updated to reflect these changes.
generated by genaiscript pr-review-commit
const url = `${apiUrl}/repos/${repository}/issues/${issue}/comments` | ||
|
||
body = appendGeneratedComment(script, info, body) | ||
|
||
if (commentTag) { | ||
const tag = `<!-- genaiscript ${commentTag} -->` |
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.
The githubCreateIssueComment
function is using a retryOn
array that is empty, which means the fetch will not retry. If retries are intended, this array should include conditions for when to retry.
generated by genaiscript pr-review-commit
Add CLI option to upload annotations as pull request comments.
-prr, --pull-request-reviews
to create pull request reviews from annotations indocs/src/content/docs/reference/cli/commands.md
andpackages/cli/src/cli.ts
.run
command the default command in the CLI by adding{ isDefault: true }
inpackages/cli/src/cli.ts
.runScript
function inpackages/cli/src/run.ts
to support the newpullRequestReviews
option.githubCreatePullRequestReviews
function inpackages/core/src/github.ts
to create pull request reviews based on annotations.parseAnnotations
function inpackages/core/src/annotations.ts
to prevent duplicate annotations by using aRecord
instead of an array.githubUpsetPullRequest
andgithubCreateIssueComment
functions inpackages/core/src/github.ts
to include the newscript
parameter and append a generated comment with a link to the run URL.GITHUB_TOKEN
constant topackages/core/src/constants.ts
for better token management.createFetch
function inpackages/core/src/fetch.ts
to returncrossFetch
directly ifretryOn
array is empty.githubCreatePullRequestReview
inpackages/core/src/github.ts
to create individual pull request review comments.runTemplate
function inpackages/core/src/promptrunner.ts
to map annotations to include the line number in the output.relativePath
function inpackages/core/src/util.ts
for better path handling.link
function inpackages/core/src/markdown.ts
to create markdown links.