Skip to content

Commit

Permalink
src/utils.js: overly complicated regex since claude cannot respect order
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed May 13, 2024
1 parent 58e1e52 commit d1e0f30
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Desired format:
<list_of_changes> // Describe the main changes in the PR, organizing them by filename
\n`

const re = /(### Changes[\s\S]*?\n)###\s/g

export async function explainPatchHelper (patchBody, owner, repo, models, debug, getResponse) {
models = Array.isArray(models) ? models : models.split(' ')

Expand Down Expand Up @@ -44,6 +46,12 @@ export async function explainPatchHelper (patchBody, owner, repo, models, debug,
}

response = response.replaceAll('### Changes', '<details>\n<summary><i>Changes</i></summary>\n\n### Changes')
response += `</details>\n\n<!-- Generated by ${model} -->`

if (re.test(response)) {
response = response.replaceAll(/(### Changes[\s\S]*?\n)###\s/g, '$1</details>\n\n### ')
} else {
response += '</details>'
}
response += `\n\n<!-- Generated by ${model} -->`
return response
}

0 comments on commit d1e0f30

Please sign in to comment.