@@ -18,20 +18,19 @@ export const COMMENT_REPLY_TAG =
18
18
export const SUMMARIZE_TAG =
19
19
'<!-- This is an auto-generated comment: summarize by openai -->'
20
20
21
- export const EXTRA_CONTENT_TAG = '<!-- Extra content -->'
22
-
23
- export const DESCRIPTION_TAG =
21
+ export const DESCRIPTION_START_TAG =
24
22
'<!-- This is an auto-generated comment: release notes by openai -->'
25
- export const DESCRIPTION_TAG_END =
23
+ export const DESCRIPTION_END_TAG =
26
24
'<!-- end of auto-generated comment: release notes by openai -->'
27
25
28
- export const RAW_SUMMARY_TAG =
29
- '<!-- This is an auto-generated comment: raw summary by openai -->'
30
- export const RAW_SUMMARY_TAG_END =
31
- '<!-- end of auto-generated comment: raw summary by openai -->'
26
+ export const RAW_SUMMARY_START_TAG = `<!-- This is an auto-generated comment: raw summary by openai -->
27
+ <!--
28
+ `
29
+ export const RAW_SUMMARY_END_TAG = `-->
30
+ <!-- end of auto-generated comment: raw summary by openai -->`
32
31
33
- export const COMMIT_ID_TAG = '<!-- commit_ids_reviewed_start -->'
34
- export const COMMIT_ID_TAG_END = '<!-- commit_ids_reviewed_end -->'
32
+ export const COMMIT_ID_START_TAG = '<!-- commit_ids_reviewed_start -->'
33
+ export const COMMIT_ID_END_TAG = '<!-- commit_ids_reviewed_end -->'
35
34
36
35
export class Commenter {
37
36
/**
@@ -89,34 +88,26 @@ ${tag}`
89
88
}
90
89
91
90
getRawSummary ( summary : string ) {
92
- const content = this . getContentWithinTags (
91
+ return this . getContentWithinTags (
93
92
summary ,
94
- RAW_SUMMARY_TAG ,
95
- RAW_SUMMARY_TAG_END
93
+ RAW_SUMMARY_START_TAG ,
94
+ RAW_SUMMARY_END_TAG
96
95
)
97
- // remove the first and last line
98
- const lines = content . split ( '\n' )
99
- if ( lines . length < 3 ) {
100
- return ''
101
- }
102
- lines . shift ( )
103
- lines . pop ( )
104
- return lines . join ( '\n' )
105
96
}
106
97
107
98
getDescription ( description : string ) {
108
99
return this . removeContentWithinTags (
109
100
description ,
110
- DESCRIPTION_TAG ,
111
- DESCRIPTION_TAG_END
101
+ DESCRIPTION_START_TAG ,
102
+ DESCRIPTION_END_TAG
112
103
)
113
104
}
114
105
115
106
getReleaseNotes ( description : string ) {
116
107
const releaseNotes = this . getContentWithinTags (
117
108
description ,
118
- DESCRIPTION_TAG ,
119
- DESCRIPTION_TAG_END
109
+ DESCRIPTION_START_TAG ,
110
+ DESCRIPTION_END_TAG
120
111
)
121
112
return releaseNotes . replace ( / ( ^ | \n ) > .* / g, '' )
122
113
}
@@ -140,10 +131,10 @@ ${tag}`
140
131
141
132
const messageClean = this . removeContentWithinTags (
142
133
message ,
143
- DESCRIPTION_TAG ,
144
- DESCRIPTION_TAG_END
134
+ DESCRIPTION_START_TAG ,
135
+ DESCRIPTION_END_TAG
145
136
)
146
- const newDescription = `${ description } \n${ DESCRIPTION_TAG } \n${ messageClean } \n${ DESCRIPTION_TAG_END } `
137
+ const newDescription = `${ description } \n${ DESCRIPTION_START_TAG } \n${ messageClean } \n${ DESCRIPTION_END_TAG } `
147
138
await octokit . pulls . update ( {
148
139
owner : repo . owner ,
149
140
repo : repo . repo ,
@@ -562,12 +553,12 @@ ${chain}
562
553
// commit ids are comments between the commit_ids_reviewed_start and commit_ids_reviewed_end markers
563
554
// <!-- [commit_id] -->
564
555
getReviewedCommitIds ( commentBody : string ) : string [ ] {
565
- const start = commentBody . indexOf ( COMMIT_ID_TAG )
566
- const end = commentBody . indexOf ( COMMIT_ID_TAG_END )
556
+ const start = commentBody . indexOf ( COMMIT_ID_START_TAG )
557
+ const end = commentBody . indexOf ( COMMIT_ID_END_TAG )
567
558
if ( start === - 1 || end === - 1 ) {
568
559
return [ ]
569
560
}
570
- const ids = commentBody . substring ( start + COMMIT_ID_TAG . length , end )
561
+ const ids = commentBody . substring ( start + COMMIT_ID_START_TAG . length , end )
571
562
// remove the <!-- and --> markers from each id and extract the id and remove empty strings
572
563
return ids
573
564
. split ( '<!--' )
@@ -578,26 +569,26 @@ ${chain}
578
569
// get review commit ids comment block from the body as a string
579
570
// including markers
580
571
getReviewedCommitIdsBlock ( commentBody : string ) : string {
581
- const start = commentBody . indexOf ( COMMIT_ID_TAG )
582
- const end = commentBody . indexOf ( COMMIT_ID_TAG_END )
572
+ const start = commentBody . indexOf ( COMMIT_ID_START_TAG )
573
+ const end = commentBody . indexOf ( COMMIT_ID_END_TAG )
583
574
if ( start === - 1 || end === - 1 ) {
584
575
return ''
585
576
}
586
- return commentBody . substring ( start , end + COMMIT_ID_TAG_END . length )
577
+ return commentBody . substring ( start , end + COMMIT_ID_END_TAG . length )
587
578
}
588
579
589
580
// add a commit id to the list of reviewed commit ids
590
581
// if the marker doesn't exist, add it
591
582
addReviewedCommitId ( commentBody : string , commitId : string ) : string {
592
- const start = commentBody . indexOf ( COMMIT_ID_TAG )
593
- const end = commentBody . indexOf ( COMMIT_ID_TAG_END )
583
+ const start = commentBody . indexOf ( COMMIT_ID_START_TAG )
584
+ const end = commentBody . indexOf ( COMMIT_ID_END_TAG )
594
585
if ( start === - 1 || end === - 1 ) {
595
- return `${ commentBody } \n${ COMMIT_ID_TAG } \n<!-- ${ commitId } -->\n${ COMMIT_ID_TAG_END } `
586
+ return `${ commentBody } \n${ COMMIT_ID_START_TAG } \n<!-- ${ commitId } -->\n${ COMMIT_ID_END_TAG } `
596
587
}
597
- const ids = commentBody . substring ( start + COMMIT_ID_TAG . length , end )
588
+ const ids = commentBody . substring ( start + COMMIT_ID_START_TAG . length , end )
598
589
return `${ commentBody . substring (
599
590
0 ,
600
- start + COMMIT_ID_TAG . length
591
+ start + COMMIT_ID_START_TAG . length
601
592
) } ${ ids } <!-- ${ commitId } -->\n${ commentBody . substring ( end ) } `
602
593
}
603
594
0 commit comments