File tree 2 files changed +30
-10
lines changed
common/changes/@microsoft/rush
libraries/rush-lib/src/logic 2 files changed +30
-10
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "changes" : [
3
+ {
4
+ "packageName" : " @microsoft/rush" ,
5
+ "comment" : " Add a more useful error message in cases when a merge base for `rush change` cannot be determined." ,
6
+ "type" : " none"
7
+ }
8
+ ],
9
+ "packageName" : " @microsoft/rush"
10
+ }
Original file line number Diff line number Diff line change @@ -230,16 +230,26 @@ export class Git {
230
230
}
231
231
232
232
const gitPath : string = this . getGitPathOrThrow ( ) ;
233
- const output : string = this . _executeGitCommandAndCaptureOutput ( gitPath , [
234
- '--no-optional-locks' ,
235
- 'merge-base' ,
236
- '--' ,
237
- 'HEAD' ,
238
- targetBranch
239
- ] ) ;
240
- const result : string = output . trim ( ) ;
241
-
242
- return result ;
233
+ try {
234
+ const output : string = this . _executeGitCommandAndCaptureOutput ( gitPath , [
235
+ '--no-optional-locks' ,
236
+ 'merge-base' ,
237
+ '--' ,
238
+ 'HEAD' ,
239
+ targetBranch
240
+ ] ) ;
241
+ const result : string = output . trim ( ) ;
242
+
243
+ return result ;
244
+ } catch ( e ) {
245
+ terminal . writeErrorLine (
246
+ `Unable to determine merge base for branch "${ targetBranch } ". ` +
247
+ 'This can occur if the current clone is a shallow clone. If this clone is running in a CI ' +
248
+ 'pipeline, check your pipeline settings to ensure that the clone depth includes ' +
249
+ 'the expected merge base. If this clone is running locally, consider running "git fetch --deepen".'
250
+ ) ;
251
+ throw new AlreadyReportedError ( ) ;
252
+ }
243
253
}
244
254
245
255
public getBlobContent ( { blobSpec, repositoryRoot } : IGetBlobOptions ) : string {
You can’t perform that action at this time.
0 commit comments