Skip to content

Commit

Permalink
always regen description
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 5, 2024
1 parent fecdf76 commit 7a753a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/genai-pr-review.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: genai pull request review
on:
pull_request:
types: [ready_for_review]
paths:
- yarn.lock
- ".github/workflows/ollama.yml"
Expand Down
15 changes: 11 additions & 4 deletions packages/core/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function githubUpdatePullRequestDescription(
commentTag: string
) {
const { apiUrl, repository, issue } = info
assert(commentTag)

if (!issue) return { updated: false, statusText: "missing issue number" }
const token = await host.readSecret(GITHUB_TOKEN)
Expand All @@ -89,15 +90,21 @@ export async function githubUpdatePullRequestDescription(
const resGetJson = (await resGet.json()) as { body: string }
let { body } = resGetJson
if (!body) body = ""
const tag = `\n\n<!-- genaiscript begin ${commentTag} -->\n\n`
const endTag = `\n\n<!-- genaiscript end ${commentTag} -->\n\n`
const tag = `<!-- genaiscript begin ${commentTag} -->`
const endTag = `<!-- genaiscript end ${commentTag} -->`
const sep = "\n\n"

const start = body.indexOf(tag)
const end = body.indexOf(endTag)
if (start > -1 && end > -1 && start < end) {
body = body.slice(0, start + tag.length) + text + body.slice(end)
body =
body.slice(0, start + tag.length) +
sep +
text +
sep +
body.slice(end)
} else {
body = body + tag + text + endTag
body = body + sep + tag + sep + text + sep + endTag + sep
}

const res = await fetch(url, {
Expand Down

0 comments on commit 7a753a2

Please sign in to comment.