@@ -42,7 +42,7 @@ import { CodeModelService } from './code-model.service';
4242import { RefType , ICodeServiceConfig , CodePlatform } from './types' ;
4343import { Configure } from './config.service' ;
4444import { ISCMRepository , SCMService , ISCMResource , ISCMResourceGroup } from '@opensumi/ide-scm' ;
45- import { CODE_PLATFORM_CONFIG } from '@alipay/alex-code-api' ;
45+ import { CODE_PLATFORM_CONFIG , RequestFailed } from '@alipay/alex-code-api' ;
4646
4747namespace CODE_SERVICE_COMMANDS {
4848 const CATEGORY = 'CodeService' ;
@@ -343,15 +343,20 @@ export class CodeContribution
343343 }
344344 if ( ! refBranches . find ( ( b ) => b . name === newBranchName ) ) {
345345 const branch = await repo . request . createBranch ( newBranchName , repo . commit ) ;
346- if ( branch ) {
346+ if ( branch ?. commit . id ) {
347347 this . messageService . info (
348348 formatLocalize ( 'code-service.command.create-branch-success' , newBranchName )
349349 ) ;
350350 await repo . refreshRepository ( branch . commit . id , branch . name ) ;
351+ } else {
352+ this . messageService . error (
353+ ( branch as any as RequestFailed ) . message ||
354+ formatLocalize ( 'code-service.command.create-branch-error' , newBranchName )
355+ ) ;
351356 }
352357 } else {
353358 this . messageService . error (
354- formatLocalize ( 'code-service.command.create-branch-error' , newBranchName )
359+ formatLocalize ( 'code-service.command.create-branch-error-exists ' , newBranchName )
355360 ) ;
356361 }
357362 } ,
@@ -367,7 +372,7 @@ export class CodeContribution
367372 }
368373 if ( repo . refs . branches . find ( ( b ) => b . name === newBranchName ) ) {
369374 this . messageService . error (
370- formatLocalize ( 'code-service.command.create-branch-error' , newBranchName )
375+ formatLocalize ( 'code-service.command.create-branch-error-exists ' , newBranchName )
371376 ) ;
372377 return ;
373378 }
@@ -389,11 +394,16 @@ export class CodeContribution
389394 if ( typeof value === 'number' ) {
390395 const target = refs [ value ] ;
391396 const branch = await repo . request . createBranch ( newBranchName , target . commit ) ;
392- if ( branch ) {
397+ if ( branch ?. commit . id ) {
393398 this . messageService . info (
394399 formatLocalize ( 'code-service.command.create-branch-success' , newBranchName )
395400 ) ;
396401 await repo . refreshRepository ( branch . commit . id , branch . name ) ;
402+ } else {
403+ this . messageService . error (
404+ ( branch as any as RequestFailed ) . message ||
405+ formatLocalize ( 'code-service.command.create-branch-error' , newBranchName )
406+ ) ;
397407 }
398408 }
399409 } ,
0 commit comments