@@ -101,6 +101,74 @@ public void CanRebase(string initialBranchName,
101
101
}
102
102
}
103
103
104
+ private class rebaseStepInfo
105
+ {
106
+ public Commit Commit { get ; set ; }
107
+ }
108
+
109
+ /// <summary>
110
+ /// Verify a single rebase, but in more detail.
111
+ /// </summary>
112
+ [ Fact ]
113
+ public void VerifyRebaseDetailed ( )
114
+ {
115
+ SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
116
+ var path = Repository . Init ( scd . DirectoryPath ) ;
117
+
118
+ using ( Repository repo = new Repository ( path ) )
119
+ {
120
+ ConstructRebaseTestRepository ( repo ) ;
121
+
122
+ Branch initialBranch = repo . Branches [ topicBranch1Name ] ;
123
+ Branch upstreamBranch = repo . Branches [ masterBranch2Name ] ;
124
+
125
+ repo . Checkout ( initialBranch ) ;
126
+ Assert . False ( repo . RetrieveStatus ( ) . IsDirty ) ;
127
+
128
+ bool wasCheckoutProgressCalled = false ;
129
+ bool wasCheckoutNotifyCalled = false ;
130
+
131
+ RebaseOptions options = new RebaseOptions ( )
132
+ {
133
+ OnCheckoutProgress = ( x , y , z ) => wasCheckoutProgressCalled = true ,
134
+ OnCheckoutNotify = ( x , y ) => { wasCheckoutNotifyCalled = true ; return true ; } ,
135
+ CheckoutNotifyFlags = CheckoutNotifyFlags . Updated ,
136
+ } ;
137
+
138
+ repo . Rebase . Start ( null , upstreamBranch , null , Constants . Signature2 , options ) ;
139
+
140
+ Assert . Equal ( true , wasCheckoutNotifyCalled ) ;
141
+ Assert . Equal ( true , wasCheckoutProgressCalled ) ;
142
+
143
+ // Verify the chain of resultant rebased commits.
144
+ CommitFilter commitFilter = new CommitFilter ( )
145
+ {
146
+ Since = repo . Head . Tip ,
147
+ Until = upstreamBranch . Tip ,
148
+ SortBy = CommitSortStrategies . Reverse | CommitSortStrategies . Topological ,
149
+ } ;
150
+
151
+ List < ObjectId > expectedTreeIds = new List < ObjectId > ( )
152
+ {
153
+ new ObjectId ( "447bad85bcc1882037848370620a6f88e8ee264e" ) ,
154
+ new ObjectId ( "3b0fc846952496a64b6149064cde21215daca8f8" ) ,
155
+ new ObjectId ( "a2d114246012daf3ef8e7ccbfbe91889a24e1e60" ) ,
156
+ } ;
157
+
158
+ List < Commit > rebasedCommits = repo . Commits . QueryBy ( commitFilter ) . ToList ( ) ;
159
+
160
+ Assert . Equal ( 3 , rebasedCommits . Count ) ;
161
+ for ( int i = 0 ; i < 3 ; i ++ )
162
+ {
163
+ Assert . Equal ( expectedTreeIds [ i ] , rebasedCommits [ i ] . Tree . Id ) ;
164
+ Assert . Equal ( Constants . Signature . Name , rebasedCommits [ i ] . Author . Name ) ;
165
+ Assert . Equal ( Constants . Signature . Email , rebasedCommits [ i ] . Author . Email ) ;
166
+ Assert . Equal ( Constants . Signature2 . Name , rebasedCommits [ i ] . Committer . Name ) ;
167
+ Assert . Equal ( Constants . Signature2 . Email , rebasedCommits [ i ] . Committer . Email ) ;
168
+ }
169
+ }
170
+ }
171
+
104
172
[ Fact ]
105
173
public void CanContinueRebase ( )
106
174
{
@@ -119,10 +187,16 @@ public void CanContinueRebase()
119
187
120
188
int beforeStepCallCount = 0 ;
121
189
int afterStepCallCount = 0 ;
190
+ bool wasCheckoutProgressCalled = false ;
191
+ bool wasCheckoutNotifyCalled = false ;
192
+
122
193
RebaseOptions options = new RebaseOptions ( )
123
194
{
124
195
RebaseStepStarting = x => beforeStepCallCount ++ ,
125
196
RebaseStepCompleted = x => afterStepCallCount ++ ,
197
+ OnCheckoutProgress = ( x , y , z ) => wasCheckoutProgressCalled = true ,
198
+ OnCheckoutNotify = ( x , y ) => { wasCheckoutNotifyCalled = true ; return true ; } ,
199
+ CheckoutNotifyFlags = CheckoutNotifyFlags . Updated | CheckoutNotifyFlags . Conflict ,
126
200
} ;
127
201
128
202
RebaseResult rebaseResult = repo . Rebase . Start ( branch , upstream , onto , Constants . Signature , options ) ;
@@ -135,8 +209,13 @@ public void CanContinueRebase()
135
209
Assert . Equal ( 0 , rebaseResult . CompletedStepCount ) ;
136
210
Assert . Equal ( 3 , rebaseResult . TotalStepCount ) ;
137
211
212
+ // Verify that expected callbacks were called
138
213
Assert . Equal ( 1 , beforeStepCallCount ) ;
139
214
Assert . Equal ( 0 , afterStepCallCount ) ;
215
+ Assert . True ( wasCheckoutProgressCalled , "CheckoutProgress callback was not called." ) ;
216
+
217
+ // TODO: investigate following statement.
218
+ // Assert.True(wasCheckoutNotifyCalled, "CheckoutNotify callback was not called.");
140
219
141
220
// Resolve the conflict
142
221
foreach ( Conflict conflict in repo . Index . Conflicts )
@@ -149,6 +228,8 @@ public void CanContinueRebase()
149
228
150
229
Assert . True ( repo . Index . IsFullyMerged ) ;
151
230
231
+ // Clear the flags:
232
+ wasCheckoutProgressCalled = false ; wasCheckoutNotifyCalled = false ;
152
233
RebaseResult continuedRebaseResult = repo . Rebase . Continue ( Constants . Signature , options ) ;
153
234
154
235
Assert . NotNull ( continuedRebaseResult ) ;
@@ -160,8 +241,8 @@ public void CanContinueRebase()
160
241
161
242
Assert . Equal ( 3 , beforeStepCallCount ) ;
162
243
Assert . Equal ( 3 , afterStepCallCount ) ;
163
-
164
- // TODO: Validate the expected HEAD commit ID
244
+ Assert . True ( wasCheckoutProgressCalled , "CheckoutProgress callback was not called." ) ;
245
+ Assert . True ( wasCheckoutNotifyCalled , "CheckoutNotify callback was not called." ) ;
165
246
}
166
247
}
167
248
0 commit comments