@@ -314,17 +314,15 @@ export class GitExtension implements IGitExtension {
314
314
*/
315
315
async allHistory ( count = 25 ) : Promise < Git . IAllHistory > {
316
316
const path = await this . _getPathRespository ( ) ;
317
- const data = await this . _taskHandler . execute < Git . IAllHistory > (
317
+ return await this . _taskHandler . execute < Git . IAllHistory > (
318
318
'git:fetch:history' ,
319
319
async ( ) => {
320
- const d = await requestAPI < Git . IAllHistory > ( 'all_history' , 'POST' , {
320
+ return await requestAPI < Git . IAllHistory > ( 'all_history' , 'POST' , {
321
321
current_path : path ,
322
322
history_count : count
323
323
} ) ;
324
- return d ;
325
324
}
326
325
) ;
327
- return data ;
328
326
}
329
327
330
328
/**
@@ -419,18 +417,16 @@ export class GitExtension implements IGitExtension {
419
417
url : string ,
420
418
auth ?: Git . IAuth
421
419
) : Promise < Git . ICloneResult > {
422
- const data = this . _taskHandler . execute < Git . ICloneResult > (
420
+ return await this . _taskHandler . execute < Git . ICloneResult > (
423
421
'git:clone' ,
424
422
async ( ) => {
425
- const d = await requestAPI < Git . ICloneResult > ( 'clone' , 'POST' , {
423
+ return await requestAPI < Git . ICloneResult > ( 'clone' , 'POST' , {
426
424
current_path : path ,
427
425
clone_url : url ,
428
426
auth : auth as any
429
427
} ) ;
430
- return d ;
431
428
}
432
429
) ;
433
- return data ;
434
430
}
435
431
436
432
/**
@@ -467,7 +463,7 @@ export class GitExtension implements IGitExtension {
467
463
*/
468
464
async config ( options ?: JSONObject ) : Promise < JSONObject | void > {
469
465
const path = await this . _getPathRespository ( ) ;
470
- const data = await this . _taskHandler . execute < JSONObject | void > (
466
+ return await this . _taskHandler . execute < JSONObject | void > (
471
467
'git:config:' + ( options ? 'set' : 'get' ) ,
472
468
async ( ) => {
473
469
if ( options ) {
@@ -476,12 +472,10 @@ export class GitExtension implements IGitExtension {
476
472
options
477
473
} ) ;
478
474
} else {
479
- const d = await requestAPI < JSONObject > ( 'config' , 'POST' , { path } ) ;
480
- return d ;
475
+ return await requestAPI < JSONObject > ( 'config' , 'POST' , { path } ) ;
481
476
}
482
477
}
483
478
) ;
484
- return data ;
485
479
}
486
480
487
481
/**
@@ -511,15 +505,14 @@ export class GitExtension implements IGitExtension {
511
505
const data = await this . _taskHandler . execute < Git . ISingleCommitFilePathInfo > (
512
506
'git:fetch:commit_log' ,
513
507
async ( ) => {
514
- const d = await requestAPI < Git . ISingleCommitFilePathInfo > (
508
+ return await requestAPI < Git . ISingleCommitFilePathInfo > (
515
509
'detailed_log' ,
516
510
'POST' ,
517
511
{
518
512
selected_hash : hash ,
519
513
current_path : path
520
514
}
521
515
) ;
522
- return d ;
523
516
}
524
517
) ;
525
518
@@ -620,17 +613,15 @@ export class GitExtension implements IGitExtension {
620
613
*/
621
614
async log ( count = 25 ) : Promise < Git . ILogResult > {
622
615
const path = await this . _getPathRespository ( ) ;
623
- const data = this . _taskHandler . execute < Git . ILogResult > (
616
+ return await this . _taskHandler . execute < Git . ILogResult > (
624
617
'git:fetch:log' ,
625
618
async ( ) => {
626
- const d = await requestAPI < Git . ILogResult > ( 'log' , 'POST' , {
619
+ return await requestAPI < Git . ILogResult > ( 'log' , 'POST' , {
627
620
current_path : path ,
628
621
history_count : count
629
622
} ) ;
630
- return d ;
631
623
}
632
624
) ;
633
- return data ;
634
625
}
635
626
636
627
/**
@@ -648,14 +639,13 @@ export class GitExtension implements IGitExtension {
648
639
const data = this . _taskHandler . execute < Git . IPushPullResult > (
649
640
'git:pull' ,
650
641
async ( ) => {
651
- const d = await requestAPI < Git . IPushPullResult > ( 'pull' , 'POST' , {
642
+ return await requestAPI < Git . IPushPullResult > ( 'pull' , 'POST' , {
652
643
current_path : path ,
653
644
auth : auth as any ,
654
645
cancel_on_conflict :
655
646
( this . _settings ?. composite [ 'cancelPullMergeConflict' ] as boolean ) ||
656
647
false
657
648
} ) ;
658
- return d ;
659
649
}
660
650
) ;
661
651
this . _headChanged . emit ( ) ;
@@ -677,11 +667,10 @@ export class GitExtension implements IGitExtension {
677
667
const data = this . _taskHandler . execute < Git . IPushPullResult > (
678
668
'git:push' ,
679
669
async ( ) => {
680
- const d = await requestAPI < Git . IPushPullResult > ( 'push' , 'POST' , {
670
+ return await requestAPI < Git . IPushPullResult > ( 'push' , 'POST' , {
681
671
current_path : path ,
682
672
auth : auth as any
683
673
} ) ;
684
- return d ;
685
674
}
686
675
) ;
687
676
this . _headChanged . emit ( ) ;
@@ -710,19 +699,29 @@ export class GitExtension implements IGitExtension {
710
699
const data = await this . _taskHandler . execute < Git . IBranchResult > (
711
700
'git:refresh:branches' ,
712
701
async ( ) => {
713
- const response = await this . _branch ( ) ;
714
- return response ;
702
+ return await this . _branch ( ) ;
715
703
}
716
704
) ;
705
+
706
+ const headChanged = this . _currentBranch !== data . current_branch ;
717
707
this . _branches = data . branches ;
718
708
this . _currentBranch = data . current_branch ;
719
709
if ( this . _currentBranch ) {
720
710
// Set up the marker obj for the current (valid) repo/branch combination
721
711
this . _setMarker ( this . pathRepository , this . _currentBranch . name ) ;
722
712
}
713
+
714
+ if ( headChanged ) {
715
+ this . _headChanged . emit ( ) ;
716
+ }
723
717
} catch ( error ) {
718
+ const headChanged = this . _currentBranch !== null ;
724
719
this . _branches = [ ] ;
725
720
this . _currentBranch = null ;
721
+ if ( headChanged ) {
722
+ this . _headChanged . emit ( ) ;
723
+ }
724
+
726
725
if ( ! ( error instanceof Git . NotInRepository ) ) {
727
726
throw error ;
728
727
}
@@ -750,10 +749,9 @@ export class GitExtension implements IGitExtension {
750
749
const data = await this . _taskHandler . execute < Git . IStatusResult > (
751
750
'git:refresh:status' ,
752
751
async ( ) => {
753
- const d = await requestAPI < Git . IStatusResult > ( 'status' , 'POST' , {
752
+ return await requestAPI < Git . IStatusResult > ( 'status' , 'POST' , {
754
753
current_path : path
755
754
} ) ;
756
- return d ;
757
755
}
758
756
) ;
759
757
@@ -853,20 +851,14 @@ export class GitExtension implements IGitExtension {
853
851
* @throws {ServerConnection.NetworkError } If the request cannot be made
854
852
*/
855
853
async showPrefix ( path : string ) : Promise < Git . IShowPrefixResult > {
856
- const data = await this . _taskHandler . execute < Git . IShowPrefixResult > (
854
+ return await this . _taskHandler . execute < Git . IShowPrefixResult > (
857
855
'git:fetch:prefix_path' ,
858
856
async ( ) => {
859
- const d = await requestAPI < Git . IShowPrefixResult > (
860
- 'show_prefix' ,
861
- 'POST' ,
862
- {
863
- current_path : path
864
- }
865
- ) ;
866
- return d ;
857
+ return await requestAPI < Git . IShowPrefixResult > ( 'show_prefix' , 'POST' , {
858
+ current_path : path
859
+ } ) ;
867
860
}
868
861
) ;
869
- return data ;
870
862
}
871
863
872
864
/**
@@ -879,20 +871,18 @@ export class GitExtension implements IGitExtension {
879
871
* @throws {ServerConnection.NetworkError } If the request cannot be made
880
872
*/
881
873
async showTopLevel ( path : string ) : Promise < Git . IShowTopLevelResult > {
882
- const data = this . _taskHandler . execute < Git . IShowTopLevelResult > (
874
+ return await this . _taskHandler . execute < Git . IShowTopLevelResult > (
883
875
'git:fetch:top_level_path' ,
884
876
async ( ) => {
885
- const d = await requestAPI < Git . IShowTopLevelResult > (
877
+ return await requestAPI < Git . IShowTopLevelResult > (
886
878
'show_top_level' ,
887
879
'POST' ,
888
880
{
889
881
current_path : path
890
882
}
891
883
) ;
892
- return d ;
893
884
}
894
885
) ;
895
- return data ;
896
886
}
897
887
898
888
/**
@@ -906,16 +896,14 @@ export class GitExtension implements IGitExtension {
906
896
*/
907
897
async tags ( ) : Promise < Git . ITagResult > {
908
898
const path = await this . _getPathRespository ( ) ;
909
- const data = await this . _taskHandler . execute < Git . ITagResult > (
899
+ return await this . _taskHandler . execute < Git . ITagResult > (
910
900
'git:tag:list' ,
911
901
async ( ) => {
912
- const d = await requestAPI < Git . ITagResult > ( 'tags' , 'POST' , {
902
+ return await requestAPI < Git . ITagResult > ( 'tags' , 'POST' , {
913
903
current_path : path
914
904
} ) ;
915
- return d ;
916
905
}
917
906
) ;
918
- return data ;
919
907
}
920
908
921
909
/**
@@ -930,21 +918,15 @@ export class GitExtension implements IGitExtension {
930
918
*/
931
919
async checkoutTag ( tag : string ) : Promise < Git . ICheckoutResult > {
932
920
const path = await this . _getPathRespository ( ) ;
933
- const data = await this . _taskHandler . execute < Git . ICheckoutResult > (
921
+ return await this . _taskHandler . execute < Git . ICheckoutResult > (
934
922
'git:tag:checkout' ,
935
923
async ( ) => {
936
- const d = await requestAPI < Git . ICheckoutResult > (
937
- 'tag_checkout' ,
938
- 'POST' ,
939
- {
940
- current_path : path ,
941
- tag_id : tag
942
- }
943
- ) ;
944
- return d ;
924
+ return await requestAPI < Git . ICheckoutResult > ( 'tag_checkout' , 'POST' , {
925
+ current_path : path ,
926
+ tag_id : tag
927
+ } ) ;
945
928
}
946
929
) ;
947
- return data ;
948
930
}
949
931
950
932
/**
@@ -1028,16 +1010,14 @@ export class GitExtension implements IGitExtension {
1028
1010
*/
1029
1011
protected async _branch ( ) : Promise < Git . IBranchResult > {
1030
1012
const path = await this . _getPathRespository ( ) ;
1031
- const data = await this . _taskHandler . execute < Git . IBranchResult > (
1013
+ return await this . _taskHandler . execute < Git . IBranchResult > (
1032
1014
'git:fetch:branches' ,
1033
1015
async ( ) => {
1034
- const d = await requestAPI < Git . IBranchResult > ( 'branch' , 'POST' , {
1016
+ return await requestAPI < Git . IBranchResult > ( 'branch' , 'POST' , {
1035
1017
current_path : path
1036
1018
} ) ;
1037
- return d ;
1038
1019
}
1039
1020
) ;
1040
- return data ;
1041
1021
}
1042
1022
1043
1023
/**
@@ -1060,17 +1040,12 @@ export class GitExtension implements IGitExtension {
1060
1040
remote ?: string ,
1061
1041
singleCommit ?: string
1062
1042
) : Promise < Git . IChangedFilesResult > {
1063
- const data = await requestAPI < Git . IChangedFilesResult > (
1064
- 'changed_files' ,
1065
- 'POST' ,
1066
- {
1067
- current_path : this . pathRepository ,
1068
- base : base ,
1069
- remote : remote ,
1070
- single_commit : singleCommit
1071
- }
1072
- ) ;
1073
- return data ;
1043
+ return await requestAPI < Git . IChangedFilesResult > ( 'changed_files' , 'POST' , {
1044
+ current_path : this . pathRepository ,
1045
+ base : base ,
1046
+ remote : remote ,
1047
+ single_commit : singleCommit
1048
+ } ) ;
1074
1049
}
1075
1050
1076
1051
/**
0 commit comments