33
44namespace SourceGit . ViewModels
55{
6+ public enum BeforeCreateBranchAction
7+ {
8+ StashAndReaply ,
9+ Discard ,
10+ DoNothing ,
11+ }
12+
613 public class CreateBranch : Popup
714 {
815 [ Required ( ErrorMessage = "Branch name is required!" ) ]
@@ -19,14 +26,14 @@ public object BasedOn
1926 get ;
2027 private set ;
2128 }
22-
23- public bool CheckoutAfterCreated
29+
30+ public BeforeCreateBranchAction PreAction
2431 {
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
3037 {
3138 get ;
3239 set ;
@@ -90,7 +97,7 @@ public override Task<bool> Sure()
9097 bool needPopStash = false ;
9198 if ( _repo . WorkingCopyChangesCount > 0 )
9299 {
93- if ( AutoStash )
100+ if ( _preAction == BeforeCreateBranchAction . StashAndReaply )
94101 {
95102 SetProgressDescription ( "Adding untracked changes..." ) ;
96103 var succ = new Commands . Add ( _repo . FullPath ) . Exec ( ) ;
@@ -108,7 +115,7 @@ public override Task<bool> Sure()
108115
109116 needPopStash = true ;
110117 }
111- else
118+ else if ( _preAction == BeforeCreateBranchAction . Discard )
112119 {
113120 SetProgressDescription ( "Discard local changes..." ) ;
114121 Commands . Discard . All ( _repo . FullPath ) ;
@@ -137,5 +144,6 @@ public override Task<bool> Sure()
137144 private readonly Repository _repo = null ;
138145 private string _name = null ;
139146 private readonly string _baseOnRevision = null ;
147+ private BeforeCreateBranchAction _preAction = BeforeCreateBranchAction . StashAndReaply ;
140148 }
141149}
0 commit comments