@@ -42,69 +42,67 @@ public override async Task<bool> Sure()
42
42
Use ( log ) ;
43
43
44
44
var updateSubmodules = IsRecurseSubmoduleVisible && RecurseSubmodules ;
45
- {
46
- bool succ ;
47
- var needPopStash = false ;
45
+ bool succ ;
46
+ var needPopStash = false ;
48
47
49
- if ( ! _repo . ConfirmCheckoutBranch ( ) )
50
- {
51
- await CallUIThreadAsync ( ( ) => _repo . SetWatcherEnabled ( true ) ) ;
52
- return true ;
53
- }
48
+ if ( ! _repo . ConfirmCheckoutBranch ( ) )
49
+ {
50
+ await CallUIThreadAsync ( ( ) => _repo . SetWatcherEnabled ( true ) ) ;
51
+ return true ;
52
+ }
54
53
55
- if ( DiscardLocalChanges )
56
- {
57
- succ = await new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . BranchAsync ( Branch , true ) ;
58
- }
59
- else
54
+ if ( DiscardLocalChanges )
55
+ {
56
+ succ = await new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . BranchAsync ( Branch , true ) ;
57
+ }
58
+ else
59
+ {
60
+ var changes = await new Commands . CountLocalChangesWithoutUntracked ( _repo . FullPath ) . ResultAsync ( ) ;
61
+ if ( changes > 0 )
60
62
{
61
- var changes = await new Commands . CountLocalChangesWithoutUntracked ( _repo . FullPath ) . ResultAsync ( ) ;
62
- if ( changes > 0 )
63
+ succ = await new Commands . Stash ( _repo . FullPath ) . Use ( log ) . PushAsync ( "CHECKOUT_AUTO_STASH" ) ;
64
+ if ( ! succ )
63
65
{
64
- succ = await new Commands . Stash ( _repo . FullPath ) . Use ( log ) . PushAsync ( "CHECKOUT_AUTO_STASH" ) ;
65
- if ( ! succ )
66
- {
67
- log . Complete ( ) ;
68
- await CallUIThreadAsync ( ( ) => _repo . SetWatcherEnabled ( true ) ) ;
69
- return false ;
70
- }
71
-
72
- needPopStash = true ;
66
+ log . Complete ( ) ;
67
+ await CallUIThreadAsync ( ( ) => _repo . SetWatcherEnabled ( true ) ) ;
68
+ return false ;
73
69
}
74
70
75
- succ = await new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . BranchAsync ( Branch , false ) ;
71
+ needPopStash = true ;
76
72
}
77
73
78
- if ( succ )
79
- {
80
- if ( updateSubmodules )
81
- {
82
- var submodules = await new Commands . QueryUpdatableSubmodules ( _repo . FullPath ) . ResultAsync ( ) ;
83
- if ( submodules . Count > 0 )
84
- await new Commands . Submodule ( _repo . FullPath ) . Use ( log ) . UpdateAsync ( submodules , true , true ) ;
85
- }
74
+ succ = await new Commands . Checkout ( _repo . FullPath ) . Use ( log ) . BranchAsync ( Branch , false ) ;
75
+ }
86
76
87
- if ( needPopStash )
88
- await new Commands . Stash ( _repo . FullPath ) . Use ( log ) . PopAsync ( "stash@{0}" ) ;
77
+ if ( succ )
78
+ {
79
+ if ( updateSubmodules )
80
+ {
81
+ var submodules = await new Commands . QueryUpdatableSubmodules ( _repo . FullPath ) . ResultAsync ( ) ;
82
+ if ( submodules . Count > 0 )
83
+ await new Commands . Submodule ( _repo . FullPath ) . Use ( log ) . UpdateAsync ( submodules , true , true ) ;
89
84
}
90
85
91
- log . Complete ( ) ;
86
+ if ( needPopStash )
87
+ await new Commands . Stash ( _repo . FullPath ) . Use ( log ) . PopAsync ( "stash@{0}" ) ;
88
+ }
92
89
93
- await CallUIThreadAsync ( ( ) =>
94
- {
95
- ProgressDescription = "Waiting for branch updated..." ;
90
+ log . Complete ( ) ;
96
91
97
- var b = _repo . Branches . Find ( x => x . IsLocal && x . Name == Branch ) ;
98
- if ( b != null && _repo . HistoriesFilterMode == Models . FilterMode . Included )
99
- _repo . SetBranchFilterMode ( b , Models . FilterMode . Included , true , false ) ;
92
+ await CallUIThreadAsync ( ( ) =>
93
+ {
94
+ ProgressDescription = "Waiting for branch updated..." ;
100
95
101
- _repo . MarkBranchesDirtyManually ( ) ;
102
- _repo . SetWatcherEnabled ( true ) ;
103
- } ) ;
96
+ var b = _repo . Branches . Find ( x => x . IsLocal && x . Name == Branch ) ;
97
+ if ( b != null && _repo . HistoriesFilterMode == Models . FilterMode . Included )
98
+ _repo . SetBranchFilterMode ( b , Models . FilterMode . Included , true , false ) ;
104
99
105
- Task . Delay ( 400 ) . Wait ( ) ;
106
- return succ ;
107
- }
100
+ _repo . MarkBranchesDirtyManually ( ) ;
101
+ _repo . SetWatcherEnabled ( true ) ;
102
+ } ) ;
103
+
104
+ Task . Delay ( 400 ) . Wait ( ) ;
105
+ return succ ;
108
106
}
109
107
110
108
private readonly Repository _repo = null ;
0 commit comments