@@ -15,6 +15,7 @@ import {
15
15
getAccessToken ,
16
16
generateNewMinorVersion ,
17
17
generateNewMajorVersion ,
18
+ isActionsStepDebug ,
18
19
} from './utils' ;
19
20
import { getGitUrlWithToken } from './context-helper' ;
20
21
@@ -63,6 +64,16 @@ export default class GitHelper {
63
64
}
64
65
}
65
66
67
+ /**
68
+ * @return {boolean } should suppress error
69
+ */
70
+ private shouldSuppressError = ( ) : boolean => ! isActionsStepDebug ( ) ;
71
+
72
+ /**
73
+ * @return {boolean } is quiet?
74
+ */
75
+ private isQuiet = ( ) : boolean => this . shouldSuppressError ( ) && ( ! this . origin || this . quietIfNotOrigin ) ;
76
+
66
77
/**
67
78
* @param {string } workDir work dir
68
79
* @param {string[] } commands commands
@@ -147,15 +158,10 @@ export default class GitHelper {
147
158
args : [ this . getRemoteName ( ) , getGitUrlWithToken ( context , this . token ) ] ,
148
159
quiet : this . isQuiet ( ) ,
149
160
altCommand : `git remote add ${ this . getRemoteName ( ) } ` ,
150
- suppressError : true ,
161
+ suppressError : this . shouldSuppressError ( ) ,
151
162
} ) ;
152
163
} ;
153
164
154
- /**
155
- * @return {boolean } is quiet?
156
- */
157
- private isQuiet = ( ) : boolean => ! this . origin || this . quietIfNotOrigin ;
158
-
159
165
/**
160
166
* @param {string } workDir work dir
161
167
* @return {Promise<string> } branch name
@@ -167,7 +173,7 @@ export default class GitHelper {
167
173
return ( await this . runCommand ( workDir , {
168
174
command : 'git rev-parse' ,
169
175
args : [ '--abbrev-ref' , 'HEAD' ] ,
170
- suppressError : true ,
176
+ suppressError : this . shouldSuppressError ( ) ,
171
177
stderrToStdout : true ,
172
178
} ) ) [ 0 ] . stdout [ 0 ] ?. trim ( ) ?? '' ;
173
179
} ;
@@ -184,7 +190,7 @@ export default class GitHelper {
184
190
args : [ `--branch=${ branch } ` , this . cloneDepth , this . getRemote ( context ) , '.' ] ,
185
191
quiet : this . isQuiet ( ) ,
186
192
altCommand : `git clone --branch=${ branch } ` ,
187
- suppressError : true ,
193
+ suppressError : this . shouldSuppressError ( ) ,
188
194
} ) ;
189
195
} ;
190
196
@@ -200,7 +206,7 @@ export default class GitHelper {
200
206
args : [ this . cloneDepth , this . getRemote ( context ) , '.' ] ,
201
207
quiet : this . isQuiet ( ) ,
202
208
altCommand : 'git clone' ,
203
- suppressError : true ,
209
+ suppressError : this . shouldSuppressError ( ) ,
204
210
} ,
205
211
{
206
212
command : 'git fetch' ,
@@ -261,7 +267,7 @@ export default class GitHelper {
261
267
this . getRemoteName ( ) ,
262
268
...( refspec ?? [ ] ) ,
263
269
] ,
264
- suppressError : true ,
270
+ suppressError : this . shouldSuppressError ( ) ,
265
271
stderrToStdout : true ,
266
272
} ) ;
267
273
} ;
@@ -295,7 +301,7 @@ export default class GitHelper {
295
301
args : [ '--prune' , '--no-recurse-submodules' , this . cloneDepth , this . getRemote ( context ) , `+refs/heads/${ branchName } :refs/remotes/${ this . getRemoteName ( ) } /${ branchName } ` ] ,
296
302
quiet : this . isQuiet ( ) ,
297
303
altCommand : `git fetch --prune --no-recurse-submodules${ this . cloneDepth } ${ this . getRemoteName ( ) } +refs/heads/${ branchName } :refs/remotes/${ this . getRemoteName ( ) } /${ branchName } ` ,
298
- suppressError : true ,
304
+ suppressError : this . shouldSuppressError ( ) ,
299
305
} ) ;
300
306
} ;
301
307
@@ -317,7 +323,7 @@ export default class GitHelper {
317
323
await this . runCommand ( workDir , {
318
324
command : 'git checkout' ,
319
325
args : [ '-b' , branch , `${ this . getRemoteName ( ) } /${ branch } ` ] ,
320
- suppressError : true ,
326
+ suppressError : this . shouldSuppressError ( ) ,
321
327
stderrToStdout : true ,
322
328
} ) ;
323
329
} ;
@@ -465,7 +471,7 @@ export default class GitHelper {
465
471
args : [ this . getRemote ( context ) , '--delete' , ...tags ] ,
466
472
quiet : this . isQuiet ( ) ,
467
473
altCommand : `git push ${ this . getRemoteName ( ) } --delete ${ tags . join ( ' ' ) } ` ,
468
- suppressError : true ,
474
+ suppressError : this . shouldSuppressError ( ) ,
469
475
} ) ) ,
470
476
) ;
471
477
await this . deleteLocalTag ( workDir , tags , splitSize ) ;
@@ -506,7 +512,7 @@ export default class GitHelper {
506
512
tags => ( {
507
513
command : 'git tag' ,
508
514
args : [ '-d' , ...tags ] ,
509
- suppressError : true ,
515
+ suppressError : this . shouldSuppressError ( ) ,
510
516
stderrToStdout : true ,
511
517
} ) ,
512
518
) ) ;
@@ -550,7 +556,7 @@ export default class GitHelper {
550
556
args : args . concat ( [ this . getRemote ( context ) , `${ branch } :refs/heads/${ branch } ` ] ) ,
551
557
quiet : this . isQuiet ( ) ,
552
558
altCommand : `git push ${ args . concat ( [ this . getRemoteName ( ) , `${ branch } :refs/heads/${ branch } ` ] ) . join ( ' ' ) } ` ,
553
- suppressError : true ,
559
+ suppressError : this . shouldSuppressError ( ) ,
554
560
} ) ;
555
561
} ;
556
562
0 commit comments