@@ -76,41 +76,54 @@ define(function (require) {
7676
7777 function refreshRemotesPicker ( ) {
7878 // Run both getRemotes and getFtpRemotes and render with Mustache the template
79- Promise . all ( [ Git . getRemotes ( ) , GitFtp . getFtpRemotes ( ) ] ) . spread ( function ( remotes , ftpRemotes ) {
80-
81- // Set default remote name and cache the remotes dropdown menu
82- var defaultRemoteName = getDefaultRemote ( ) ,
83- $remotesDropdown = $gitPanel . find ( ".git-remotes-dropdown" ) ,
84- $remotesDropdownList = "" ;
85-
86- // Disable Git-push and Git-pull if there are not remotes defined
87- $gitPanel . find ( ".git-pull, .git-push" ) . prop ( "disabled" , ( remotes . length === 0 && ftpRemotes . length === 0 ) ) ;
88-
89- // Add options to change remote
90- remotes = $ . map ( remotes , function ( remote ) {
91- return {
92- "name" : remote . name ,
93- "deletable" : ( remote . name !== "origin" ) ? true : false
94- } ;
95- } ) ;
79+ Promise . settle ( [ Git . getRemotes ( ) , GitFtp . getRemotes ( ) ] ) . spread ( function ( remotes , ftpRemotes ) {
80+
81+ // If Git.getRemotes was fulfilled and (GitFtp.getRemotes was fulfilled or disabled)...
82+ if ( remotes . isFulfilled ( ) && ( ftpRemotes . isFulfilled ( ) || ! gitFtpEnabled ) ) {
83+
84+ // Set default remote name and cache the remotes dropdown menu
85+ var defaultRemoteName = getDefaultRemote ( ) ,
86+ $remotesDropdown = $gitPanel . find ( ".git-remotes-dropdown" ) ,
87+ $remotesDropdownList = "" ;
88+
89+ // Disable Git-push and Git-pull if there are not remotes defined
90+ $gitPanel
91+ . find ( ".git-pull, .git-push" )
92+ . prop ( "disabled" , ( remotes . _settledValue . length === 0 && ftpRemotes . _settledValue . length === 0 ) ) ;
93+
94+ // Add options to change remote
95+ remotes . _settledValue = $ . map ( remotes . _settledValue , function ( remote ) {
96+ return {
97+ "name" : remote . name ,
98+ "deletable" : ( remote . name !== "origin" ) ? true : false
99+ } ;
100+ } ) ;
96101
97- // Pass to Mustache the needed data
98- $remotesDropdownList = Mustache . render ( gitRemotesPickerTemplate , {
99- Strings : Strings ,
100- remotes : remotes ,
101- ftpRemotes : ftpRemotes ,
102- hasRemotes : remotes . length ? true : false ,
103- hasFtpRemotes : ftpRemotes . length ? true : false ,
104- gitFtpEnabled : gitFtpEnabled
105- } ) ;
102+ // Pass to Mustache the needed data
103+ $remotesDropdownList = Mustache . render ( gitRemotesPickerTemplate , {
104+ Strings : Strings ,
105+ remotes : remotes . _settledValue ,
106+ ftpRemotes : ftpRemotes . _settledValue ,
107+ hasRemotes : remotes . _settledValue . length ? true : false ,
108+ hasFtpRemotes : ftpRemotes . _settledValue . length ? true : false ,
109+ gitFtpEnabled : gitFtpEnabled
110+ } ) ;
106111
107- // Inject the rendered template inside the $remotesDropdown
108- $remotesDropdown . html ( $remotesDropdownList ) ;
112+ // Inject the rendered template inside the $remotesDropdown
113+ $remotesDropdown . html ( $remotesDropdownList ) ;
109114
110- if ( remotes . length !== 0 ) {
111- selectRemote ( defaultRemoteName ) ;
112- } else {
113- clearRemotePicker ( ) ;
115+ if ( remotes . _settledValue . length !== 0 ) {
116+ selectRemote ( defaultRemoteName ) ;
117+ } else {
118+ clearRemotePicker ( ) ;
119+ }
120+ }
121+ // Git.getRemotes was not fulfilled or (GitFtp.getRemotes was not fulfilled and enabled)...
122+ else {
123+ ErrorHandler . showError ( remotes . error ( ) , "Git remotes fetching failed." ) ;
124+ if ( ftpRemotes . isRejected ( ) && gitFtpEnabled ) {
125+ ErrorHandler . showError ( ftpRemotes . error ( ) , "Git-FTP remotes fetching failed." ) ;
126+ }
114127 }
115128
116129 } ) ;
0 commit comments