File tree Expand file tree Collapse file tree 4 files changed +48
-17
lines changed
Expand file tree Collapse file tree 4 files changed +48
-17
lines changed Original file line number Diff line number Diff line change @@ -11,5 +11,8 @@ trim_trailing_whitespace = true
1111[* .yml ]
1212indent_size = 2
1313
14+ [* .ts ]
15+ indent_size = 2
16+
1417[package.json ]
1518indent_size = 2
Original file line number Diff line number Diff line change @@ -5053,10 +5053,11 @@ class GithubManager {
50535053 return true;
50545054 }
50555055 catch (error) {
5056- if (error.name === 'HttpError' && error.status === 404) {
5056+ const err = error;
5057+ if (err.name === 'HttpError' && err.status === 404) {
50575058 return false;
50585059 }
5059- throw new Error(`Failed to check if branch ${branch} exist; ${util_1.inspect(error )}`);
5060+ throw new Error(`Failed to check if branch ${branch} exist; ${util_1.inspect(err )}`);
50605061 }
50615062 })
50625063 };
@@ -5075,11 +5076,12 @@ class GithubManager {
50755076 });
50765077 }
50775078 catch (error) {
5078- core.debug(util_1.inspect(error));
5079- if (!!error.errors &&
5080- (error.errors[0].message.include('No commits between') ||
5081- error.errors[0].message.include('A pull request already exists for'))) {
5082- core.info(error.errors[0].message);
5079+ const err = error;
5080+ core.debug(util_1.inspect(err));
5081+ if (err.name === 'HttpError' &&
5082+ (err.message.includes('No commits between') ||
5083+ err.message.includes('A pull request already exists for'))) {
5084+ core.info(err.message);
50835085 process.exit(0); // there is currently no neutral exit code
50845086 }
50855087 else {
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ import {
1111 IGithubManager ,
1212 IGithubManagerBranch ,
1313 IGithubManagerPulls ,
14- IGithubManagerRepos
14+ IGithubManagerRepos ,
15+ OctokitHttpError
1516} from './interfaces'
1617
1718const IS_WINDOWS = process . platform === 'win32'
@@ -82,12 +83,14 @@ export class GithubManager implements IGithubManager {
8283
8384 return true
8485 } catch ( error ) {
85- if ( error . name === 'HttpError' && error . status === 404 ) {
86+ const err : OctokitHttpError = error
87+
88+ if ( err . name === 'HttpError' && err . status === 404 ) {
8689 return false
8790 }
8891
8992 throw new Error (
90- `Failed to check if branch ${ branch } exist; ${ inspect ( error ) } `
93+ `Failed to check if branch ${ branch } exist; ${ inspect ( err ) } `
9194 )
9295 }
9396 }
@@ -114,16 +117,16 @@ export class GithubManager implements IGithubManager {
114117 body
115118 } )
116119 } catch ( error ) {
117- core . debug ( inspect ( error ) )
120+ const err : OctokitHttpError = error
121+
122+ core . debug ( inspect ( err ) )
118123
119124 if (
120- ! ! error . errors &&
121- ( error . errors [ 0 ] . message . include ( 'No commits between' ) ||
122- error . errors [ 0 ] . message . include (
123- 'A pull request already exists for'
124- ) )
125+ err . name === 'HttpError' &&
126+ ( err . message . includes ( 'No commits between' ) ||
127+ err . message . includes ( 'A pull request already exists for' ) )
125128 ) {
126- core . info ( error . errors [ 0 ] . message )
129+ core . info ( err . message )
127130
128131 process . exit ( 0 ) // there is currently no neutral exit code
129132 } else {
Original file line number Diff line number Diff line change 11import { URL } from 'url'
2+ import { RequestOptions , ResponseHeaders } from '@octokit/types'
23
34export interface IPayloadRepository {
45 full_name ?: string
@@ -211,3 +212,25 @@ export interface ISettings {
211212
212213 clean : boolean
213214}
215+
216+ export interface OctokitHttpError extends Error {
217+ name : string
218+ /**
219+ * http status code
220+ */
221+ status : number
222+ /**
223+ * http status code
224+ *
225+ * @deprecated `error.code` is deprecated in favor of `error.status`
226+ */
227+ code : number
228+ /**
229+ * error response headers
230+ */
231+ headers : ResponseHeaders
232+ /**
233+ * Request options that lead to the error.
234+ */
235+ request : RequestOptions
236+ }
You can’t perform that action at this time.
0 commit comments