@@ -10,6 +10,7 @@ import {
10
10
} from "@changesets/types" ;
11
11
import markdownTable from "markdown-table" ;
12
12
import { captureException } from "@sentry/node" ;
13
+ import { ValidationError } from "@changesets/errors" ;
13
14
14
15
const getReleasePlanMessage = ( releasePlan : ReleasePlan | null ) => {
15
16
if ( ! releasePlan ) return "" ;
@@ -125,33 +126,21 @@ const getChangesetId = (
125
126
)
126
127
) ;
127
128
128
- async function fetchJsonFile ( context : PRContext , path : string ) {
129
- let output = await context . github . repos . getContents ( {
130
- owner : context . payload . pull_request . head . repo . owner . login ,
131
- repo : context . payload . pull_request . head . repo . name ,
132
- path,
133
- ref : context . payload . pull_request . head . ref ,
134
- } ) ;
135
- // @ts -ignore
136
- let buffer = Buffer . from ( output . data . content , "base64" ) ;
137
- return JSON . parse ( buffer . toString ( "utf8" ) ) ;
138
- }
139
-
140
129
export default ( app : Application ) => {
141
130
app . auth ( ) ;
142
131
app . log ( "Yay, the app was loaded!" ) ;
143
132
144
133
app . on (
145
134
[ "pull_request.opened" , "pull_request.synchronize" ] ,
146
- // @ts -ignore
147
135
async ( context : PRContext ) => {
148
- context ;
149
136
if (
150
137
context . payload . pull_request . head . ref . startsWith ( "changeset-release" )
151
138
) {
152
139
return ;
153
140
}
154
141
142
+ let errFromFetchingChangedFiles = "" ;
143
+
155
144
try {
156
145
let number = context . payload . number ;
157
146
@@ -195,8 +184,12 @@ export default (app: Application) => {
195
184
} )
196
185
) . data . token ,
197
186
} ) . catch ( ( err ) => {
198
- console . error ( err ) ;
199
- captureException ( err ) ;
187
+ if ( err instanceof ValidationError ) {
188
+ errFromFetchingChangedFiles = `<details><summary>💥 An error occurred when fetching the changed packages in this PR</summary>\n\n\`\`\`\n${ err . message } \`\`\`\n\n</details>\n` ;
189
+ } else {
190
+ console . error ( err ) ;
191
+ captureException ( err ) ;
192
+ }
200
193
return {
201
194
changedPackages : [ "@fake-scope/fake-pkg" ] ,
202
195
releasePlan : null ,
@@ -220,9 +213,14 @@ export default (app: Application) => {
220
213
...repo ,
221
214
comment_id : commentId ,
222
215
issue_number : number ,
223
- body : hasChangeset
224
- ? getApproveMessage ( latestCommitSha , addChangesetUrl , releasePlan )
225
- : getAbsentMessage ( latestCommitSha , addChangesetUrl , releasePlan ) ,
216
+ body :
217
+ ( hasChangeset
218
+ ? getApproveMessage ( latestCommitSha , addChangesetUrl , releasePlan )
219
+ : getAbsentMessage (
220
+ latestCommitSha ,
221
+ addChangesetUrl ,
222
+ releasePlan
223
+ ) ) + errFromFetchingChangedFiles ,
226
224
} ;
227
225
228
226
if ( prComment . comment_id != null ) {
0 commit comments