@@ -13,7 +13,8 @@ const localize = nls.loadMessageBundle();
13
13
14
14
interface ActionButtonState {
15
15
readonly HEAD : Branch | undefined ;
16
- readonly isActionRunning : boolean ;
16
+ readonly isCommitInProgress : boolean ;
17
+ readonly isSyncInProgress : boolean ;
17
18
readonly repositoryHasChanges : boolean ;
18
19
}
19
20
@@ -33,7 +34,7 @@ export class ActionButtonCommand {
33
34
private disposables : Disposable [ ] = [ ] ;
34
35
35
36
constructor ( readonly repository : Repository ) {
36
- this . _state = { HEAD : undefined , isActionRunning : false , repositoryHasChanges : false } ;
37
+ this . _state = { HEAD : undefined , isCommitInProgress : false , isSyncInProgress : false , repositoryHasChanges : false } ;
37
38
38
39
repository . onDidRunGitStatus ( this . onDidRunGitStatus , this , this . disposables ) ;
39
40
repository . onDidChangeOperations ( this . onDidChangeOperations , this , this . disposables ) ;
@@ -75,21 +76,21 @@ export class ActionButtonCommand {
75
76
switch ( postCommitCommand ) {
76
77
case 'push' : {
77
78
title = localize ( 'scm button commit and push title' , "$(arrow-up) Commit & Push" ) ;
78
- tooltip = this . state . isActionRunning ?
79
+ tooltip = this . state . isCommitInProgress ?
79
80
localize ( 'scm button committing pushing tooltip' , "Committing & Pushing Changes..." ) :
80
81
localize ( 'scm button commit push tooltip' , "Commit & Push Changes" ) ;
81
82
break ;
82
83
}
83
84
case 'sync' : {
84
85
title = localize ( 'scm button commit and sync title' , "$(sync) Commit & Sync" ) ;
85
- tooltip = this . state . isActionRunning ?
86
+ tooltip = this . state . isCommitInProgress ?
86
87
localize ( 'scm button committing synching tooltip' , "Committing & Synching Changes..." ) :
87
88
localize ( 'scm button commit sync tooltip' , "Commit & Sync Changes" ) ;
88
89
break ;
89
90
}
90
91
default : {
91
92
title = localize ( 'scm button commit title' , "$(check) Commit" ) ;
92
- tooltip = this . state . isActionRunning ?
93
+ tooltip = this . state . isCommitInProgress ?
93
94
localize ( 'scm button committing tooltip' , "Committing Changes..." ) :
94
95
localize ( 'scm button commit tooltip' , "Commit Changes" ) ;
95
96
break ;
@@ -122,65 +123,67 @@ export class ActionButtonCommand {
122
123
} ,
123
124
]
124
125
] ,
125
- enabled : this . state . repositoryHasChanges && ! this . state . isActionRunning
126
+ enabled : this . state . repositoryHasChanges && ! this . state . isCommitInProgress
126
127
} ;
127
128
}
128
129
129
130
private getPublishBranchActionButton ( ) : SourceControlActionButton | undefined {
130
131
const config = workspace . getConfiguration ( 'git' , Uri . file ( this . repository . root ) ) ;
131
132
const showActionButton = config . get < { publish : boolean } > ( 'showActionButton' , { publish : true } ) ;
132
133
133
- // Branch does have an upstream or the button is disabled
134
- if ( this . state . HEAD ?. upstream || ! showActionButton . publish ) { return undefined ; }
134
+ // Branch does have an upstream, commit is in progress, or the button is disabled
135
+ if ( this . state . HEAD ?. upstream || this . state . isCommitInProgress || ! showActionButton . publish ) { return undefined ; }
135
136
136
137
return {
137
138
command : {
138
139
command : 'git.publish' ,
139
140
title : localize ( 'scm publish branch action button title' , "{0} Publish Branch" , '$(cloud-upload)' ) ,
140
- tooltip : this . state . isActionRunning ?
141
+ tooltip : this . state . isSyncInProgress ?
141
142
localize ( 'scm button publish branch running' , "Publishing Branch..." ) :
142
143
localize ( 'scm button publish branch' , "Publish Branch" ) ,
143
144
arguments : [ this . repository . sourceControl ] ,
144
145
} ,
145
- enabled : ! this . state . isActionRunning
146
+ enabled : ! this . state . isSyncInProgress
146
147
} ;
147
148
}
148
149
149
150
private getSyncChangesActionButton ( ) : SourceControlActionButton | undefined {
150
151
const config = workspace . getConfiguration ( 'git' , Uri . file ( this . repository . root ) ) ;
151
152
const showActionButton = config . get < { sync : boolean } > ( 'showActionButton' , { sync : true } ) ;
152
153
153
- // Branch does not have an upstream or the button is disabled
154
- if ( ! this . state . HEAD ?. upstream || ! showActionButton . sync ) { return undefined ; }
154
+ // Branch does not have an upstream, commit is in progress, or the button is disabled
155
+ if ( ! this . state . HEAD ?. upstream || this . state . isCommitInProgress || ! showActionButton . sync ) { return undefined ; }
155
156
156
157
const ahead = this . state . HEAD . ahead ? ` ${ this . state . HEAD . ahead } $(arrow-up)` : '' ;
157
158
const behind = this . state . HEAD . behind ? ` ${ this . state . HEAD . behind } $(arrow-down)` : '' ;
158
- const icon = this . state . isActionRunning ? '$(sync~spin)' : '$(sync)' ;
159
+ const icon = this . state . isSyncInProgress ? '$(sync~spin)' : '$(sync)' ;
159
160
160
161
const rebaseWhenSync = config . get < string > ( 'rebaseWhenSync' ) ;
161
162
162
163
return {
163
164
command : {
164
165
command : rebaseWhenSync ? 'git.syncRebase' : 'git.sync' ,
165
166
title : `${ icon } ${ behind } ${ ahead } ` ,
166
- tooltip : this . state . isActionRunning ?
167
+ tooltip : this . state . isSyncInProgress ?
167
168
localize ( 'syncing changes' , "Synchronizing Changes..." )
168
169
: this . repository . syncTooltip ,
169
170
arguments : [ this . repository . sourceControl ] ,
170
171
} ,
171
172
description : localize ( 'scm button sync description' , "{0} Sync Changes{1}{2}" , icon , behind , ahead ) ,
172
- enabled : ! this . state . isActionRunning
173
+ enabled : ! this . state . isSyncInProgress
173
174
} ;
174
175
}
175
176
176
177
private onDidChangeOperations ( ) : void {
177
- const isActionRunning =
178
+ const isCommitInProgress =
179
+ this . repository . operations . isRunning ( Operation . Commit ) ;
180
+
181
+ const isSyncInProgress =
178
182
this . repository . operations . isRunning ( Operation . Sync ) ||
179
183
this . repository . operations . isRunning ( Operation . Push ) ||
180
- this . repository . operations . isRunning ( Operation . Pull ) ||
181
- this . repository . operations . isRunning ( Operation . Commit ) ;
184
+ this . repository . operations . isRunning ( Operation . Pull ) ;
182
185
183
- this . state = { ...this . state , isActionRunning } ;
186
+ this . state = { ...this . state , isCommitInProgress , isSyncInProgress } ;
184
187
}
185
188
186
189
private onDidRunGitStatus ( ) : void {
0 commit comments