3
3
4
4
namespace SourceGit . ViewModels
5
5
{
6
+ public enum BeforeCreateBranchAction
7
+ {
8
+ StashAndReaply ,
9
+ Discard ,
10
+ DoNothing ,
11
+ }
12
+
6
13
public class CreateBranch : Popup
7
14
{
8
15
[ Required ( ErrorMessage = "Branch name is required!" ) ]
@@ -19,14 +26,14 @@ public object BasedOn
19
26
get ;
20
27
private set ;
21
28
}
22
-
23
- public bool CheckoutAfterCreated
29
+
30
+ public BeforeCreateBranchAction PreAction
24
31
{
25
- get ;
26
- set ;
27
- } = true ;
28
-
29
- public bool AutoStash
32
+ get => _preAction ;
33
+ set => SetProperty ( ref _preAction , value ) ;
34
+ }
35
+
36
+ public bool CheckoutAfterCreated
30
37
{
31
38
get ;
32
39
set ;
@@ -90,7 +97,7 @@ public override Task<bool> Sure()
90
97
bool needPopStash = false ;
91
98
if ( _repo . WorkingCopyChangesCount > 0 )
92
99
{
93
- if ( AutoStash )
100
+ if ( _preAction == BeforeCreateBranchAction . StashAndReaply )
94
101
{
95
102
SetProgressDescription ( "Adding untracked changes..." ) ;
96
103
var succ = new Commands . Add ( _repo . FullPath ) . Exec ( ) ;
@@ -108,7 +115,7 @@ public override Task<bool> Sure()
108
115
109
116
needPopStash = true ;
110
117
}
111
- else
118
+ else if ( _preAction == BeforeCreateBranchAction . Discard )
112
119
{
113
120
SetProgressDescription ( "Discard local changes..." ) ;
114
121
Commands . Discard . All ( _repo . FullPath ) ;
@@ -137,5 +144,6 @@ public override Task<bool> Sure()
137
144
private readonly Repository _repo = null ;
138
145
private string _name = null ;
139
146
private readonly string _baseOnRevision = null ;
147
+ private BeforeCreateBranchAction _preAction = BeforeCreateBranchAction . StashAndReaply ;
140
148
}
141
149
}
0 commit comments