File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ import {
19
19
import { Git , IGitExtension } from '../tokens' ;
20
20
import { NewBranchBox } from './NewBranchBox' ;
21
21
22
+ const CHANGES_ERR_MSG =
23
+ 'You have files with changes in current branch. Please commit or discard changed files before' ;
24
+
22
25
export interface IBranchHeaderState {
23
26
dropdownOpen : boolean ;
24
27
showNewBranchBox : boolean ;
@@ -79,7 +82,7 @@ export class BranchHeader extends React.Component<
79
82
} else {
80
83
showErrorMessage (
81
84
'Switching branch disabled' ,
82
- 'You have staged changes in current branch. Please commit / discard them before switching to another branch.'
85
+ CHANGES_ERR_MSG + ' switching to another branch.'
83
86
) ;
84
87
}
85
88
}
@@ -102,7 +105,7 @@ export class BranchHeader extends React.Component<
102
105
} else {
103
106
showErrorMessage (
104
107
'Creating new branch disabled' ,
105
- 'You have staged changes in current branch. Please commit / discard them before creating a new branch.'
108
+ CHANGES_ERR_MSG + ' creating a new branch.'
106
109
) ;
107
110
}
108
111
} ;
Original file line number Diff line number Diff line change @@ -188,6 +188,12 @@ export class GitPanel extends React.Component<
188
188
}
189
189
190
190
if ( this . state . inGitRepository ) {
191
+ const disableBranchOps = Boolean (
192
+ this . props . settings . composite [ 'disableBranchWithChanges' ] &&
193
+ ( ( this . state . unstagedFiles && this . state . unstagedFiles . length ) ||
194
+ ( this . state . stagedFiles && this . state . stagedFiles . length ) )
195
+ ) ;
196
+
191
197
main = (
192
198
< React . Fragment >
193
199
< BranchHeader
@@ -197,12 +203,7 @@ export class GitPanel extends React.Component<
197
203
upstreamBranch = { this . state . upstreamBranch }
198
204
stagedFiles = { this . state . stagedFiles }
199
205
data = { this . state . branches }
200
- disabled = {
201
- this . state . pastCommits . length === 0 ||
202
- ( this . props . settings . composite [
203
- 'disableBranchWithChanges'
204
- ] as boolean )
205
- }
206
+ disabled = { disableBranchOps }
206
207
toggleSidebar = { this . toggleSidebar }
207
208
sideBarExpanded = { this . state . isHistoryVisible }
208
209
/>
You can’t perform that action at this time.
0 commit comments