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

Commit c236ecc

Browse files
authored
update default prompts to use release_notes instead of full summary (#203)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Release Notes** New Feature: The GitHub Action now extracts release notes from pull request descriptions instead of using the full summary. This improves the user experience by providing more relevant prompts for reviewers and ensures consistency across different pull requests. Bug Fix: The `review.ts` file is updated to remove ">" characters from release notes. Refactor: Several files are modified to use release notes as default prompts and include error handling and token count checks. > "Release notes extracted with ease, > Reviewers' prompts now aim to please. > Consistency and relevance abound, > With fewer bugs to be found." <!-- end of auto-generated comment: release notes by openai -->
1 parent f9fb692 commit c236ecc

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

action.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,16 @@ inputs:
177177
$description
178178
```
179179
180-
OpenAI generated summary of overall changes:
180+
OpenAI generated notes:
181181
```
182-
$summary
182+
$release_notes
183183
```
184184
185-
Content of `$filename` prior to changes for context:
185+
Content of `$filename` prior to changes:
186186
```
187187
$file_content
188188
```
189189
190-
Changes for review:
191190
$patches
192191
comment:
193192
required: false
@@ -205,9 +204,9 @@ inputs:
205204
$description
206205
```
207206
208-
OpenAI generated summary:
207+
OpenAI generated notes:
209208
```
210-
$summary
209+
$release_notes
211210
```
212211
213212
Content of file prior to changes:

dist/index.js

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commenter.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ ${tag}`
7474
return description
7575
}
7676

77+
get_release_notes(description: string) {
78+
// get our summary from description by looking for description_tag and description_tag_end
79+
// and remove any content within that which is in markdown quote (>)
80+
const start = description.indexOf(DESCRIPTION_TAG)
81+
const end = description.indexOf(DESCRIPTION_TAG_END)
82+
if (start >= 0 && end >= 0) {
83+
const release_notes = description.slice(
84+
start + DESCRIPTION_TAG.length,
85+
end
86+
)
87+
return release_notes.replace(/(^|\n)> .*/g, '')
88+
}
89+
return ''
90+
}
91+
7792
async update_description(pull_number: number, message: string) {
7893
// add this response to the description field of the PR as release notes by looking
7994
// for the tag (marker)

src/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class Inputs {
4848
title: string
4949
description: string
5050
summary: string
51+
release_notes: string
5152
filename: string
5253
file_content: string
5354
file_diff: string
@@ -61,6 +62,7 @@ export class Inputs {
6162
title = 'no title provided',
6263
description = 'no description provided',
6364
summary = 'no summary so far',
65+
release_notes = 'no release notes so far',
6466
filename = 'unknown',
6567
file_content = 'file contents cannot be provided',
6668
file_diff = 'file diff cannot be provided',
@@ -73,6 +75,7 @@ export class Inputs {
7375
this.title = title
7476
this.description = description
7577
this.summary = summary
78+
this.release_notes = release_notes
7679
this.filename = filename
7780
this.file_content = file_content
7881
this.file_diff = file_diff
@@ -88,6 +91,7 @@ export class Inputs {
8891
this.title,
8992
this.description,
9093
this.summary,
94+
this.release_notes,
9195
this.filename,
9296
this.file_content,
9397
this.file_diff,
@@ -114,6 +118,9 @@ export class Inputs {
114118
if (this.summary) {
115119
content = content.replace('$summary', this.summary)
116120
}
121+
if (this.release_notes) {
122+
content = content.replace('$release_notes', this.release_notes)
123+
}
117124
if (this.filename) {
118125
content = content.replace('$filename', this.filename)
119126
}

src/review-comment.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export const handleReviewComment = async (
4747
}
4848
inputs.title = context.payload.pull_request.title
4949
if (context.payload.pull_request.body) {
50-
inputs.description = context.payload.pull_request.body
50+
inputs.description = commenter.get_description(
51+
context.payload.pull_request.body
52+
)
53+
inputs.release_notes = commenter.get_release_notes(
54+
context.payload.pull_request.body
55+
)
5156
}
5257

5358
// check if the comment was created and not edited or deleted

src/review.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ ${filename}: ${summary}
285285
core.info('release notes: nothing obtained from openai')
286286
} else {
287287
next_summarize_ids = release_notes_ids
288+
inputs.release_notes = release_notes_response.replace(/(^|\n)> .*/g, '')
288289
let message = '### Summary by OpenAI\n\n'
289290
message += release_notes_response
290291
commenter.update_description(context.payload.pull_request.number, message)

0 commit comments

Comments
 (0)