|
1 | 1 | using System;
|
2 |
| -using System.Collections.Generic; |
3 |
| -using System.Linq; |
4 |
| -using System.Text; |
5 | 2 | using LibGit2Sharp.Core;
|
6 | 3 | using LibGit2Sharp.Core.Handles;
|
7 | 4 |
|
@@ -39,11 +36,11 @@ public enum RebaseStepOperation
|
39 | 36 | /// </summary>
|
40 | 37 | Fixup,
|
41 | 38 |
|
42 |
| - /// <summary> |
43 |
| - /// No commit to cherry-pick. Run the given command and continue |
44 |
| - /// if successful. |
45 |
| - /// </summary> |
46 |
| - Exec |
| 39 | + // <summary> |
| 40 | + // No commit to cherry-pick. Run the given command and continue |
| 41 | + // if successful. |
| 42 | + // </summary> |
| 43 | + // Exec |
47 | 44 | }
|
48 | 45 |
|
49 | 46 | /// <summary>
|
@@ -169,17 +166,18 @@ public virtual RebaseResult Continue(Identity committer, RebaseOptions options)
|
169 | 166 |
|
170 | 167 | var stepInfo = new RebaseStepInfo(gitRebasestepInfo.type,
|
171 | 168 | repository.Lookup<Commit>(new ObjectId(gitRebasestepInfo.id)),
|
172 |
| - LaxUtf8NoCleanupMarshaler.FromNative(gitRebasestepInfo.exec), |
173 |
| - currentStepIndex, |
174 |
| - totalStepCount); |
| 169 | + LaxUtf8NoCleanupMarshaler.FromNative(gitRebasestepInfo.exec)); |
175 | 170 |
|
176 | 171 | if (rebaseCommitResult.WasPatchAlreadyApplied)
|
177 | 172 | {
|
178 |
| - options.RebaseStepCompleted(new AfterRebaseStepInfo(stepInfo)); |
| 173 | + options.RebaseStepCompleted(new AfterRebaseStepInfo(stepInfo, currentStepIndex, totalStepCount)); |
179 | 174 | }
|
180 | 175 | else
|
181 | 176 | {
|
182 |
| - options.RebaseStepCompleted(new AfterRebaseStepInfo(stepInfo, repository.Lookup<Commit>(new ObjectId(rebaseCommitResult.CommitId)))); |
| 177 | + options.RebaseStepCompleted(new AfterRebaseStepInfo(stepInfo, |
| 178 | + repository.Lookup<Commit>(new ObjectId(rebaseCommitResult.CommitId)), |
| 179 | + currentStepIndex, |
| 180 | + totalStepCount)); |
183 | 181 | }
|
184 | 182 | }
|
185 | 183 |
|
@@ -239,17 +237,75 @@ public virtual RebaseStepInfo GetCurrentStepInfo()
|
239 | 237 | using (RebaseSafeHandle rebaseHandle = Proxy.git_rebase_open(repository.Handle, gitRebaseOptions))
|
240 | 238 | {
|
241 | 239 | long currentStepIndex = Proxy.git_rebase_operation_current(rebaseHandle);
|
242 |
| - long totalStepCount = Proxy.git_rebase_operation_entrycount(rebaseHandle); |
243 | 240 | GitRebaseOperation gitRebasestepInfo = Proxy.git_rebase_operation_byindex(rebaseHandle, currentStepIndex);
|
244 | 241 | var stepInfo = new RebaseStepInfo(gitRebasestepInfo.type,
|
245 | 242 | repository.Lookup<Commit>(new ObjectId(gitRebasestepInfo.id)),
|
246 |
| - LaxUtf8NoCleanupMarshaler.FromNative(gitRebasestepInfo.exec), |
247 |
| - currentStepIndex, |
248 |
| - totalStepCount); |
| 243 | + LaxUtf8Marshaler.FromNative(gitRebasestepInfo.exec)); |
249 | 244 | return stepInfo;
|
250 | 245 | }
|
251 | 246 | }
|
252 | 247 |
|
| 248 | + /// <summary> |
| 249 | + /// Get info on the specified step |
| 250 | + /// </summary> |
| 251 | + /// <param name="stepIndex"></param> |
| 252 | + /// <returns></returns> |
| 253 | + public virtual RebaseStepInfo GetStepInfo(long stepIndex) |
| 254 | + { |
| 255 | + if (repository.Info.CurrentOperation != LibGit2Sharp.CurrentOperation.RebaseMerge) |
| 256 | + { |
| 257 | + return null; |
| 258 | + } |
| 259 | + |
| 260 | + GitRebaseOptions gitRebaseOptions = new GitRebaseOptions() |
| 261 | + { |
| 262 | + version = 1, |
| 263 | + }; |
| 264 | + |
| 265 | + using (RebaseSafeHandle rebaseHandle = Proxy.git_rebase_open(repository.Handle, gitRebaseOptions)) |
| 266 | + { |
| 267 | + GitRebaseOperation gitRebasestepInfo = Proxy.git_rebase_operation_byindex(rebaseHandle, stepIndex); |
| 268 | + var stepInfo = new RebaseStepInfo(gitRebasestepInfo.type, |
| 269 | + repository.Lookup<Commit>(new ObjectId(gitRebasestepInfo.id)), |
| 270 | + LaxUtf8Marshaler.FromNative(gitRebasestepInfo.exec)); |
| 271 | + return stepInfo; |
| 272 | + } |
| 273 | + } |
| 274 | + |
| 275 | + /// <summary> |
| 276 | + /// |
| 277 | + /// </summary> |
| 278 | + /// <returns></returns> |
| 279 | + public virtual long GetCurrentStepIndex() |
| 280 | + { |
| 281 | + GitRebaseOptions gitRebaseOptions = new GitRebaseOptions() |
| 282 | + { |
| 283 | + version = 1, |
| 284 | + }; |
| 285 | + |
| 286 | + using (RebaseSafeHandle rebaseHandle = Proxy.git_rebase_open(repository.Handle, gitRebaseOptions)) |
| 287 | + { |
| 288 | + return Proxy.git_rebase_operation_current(rebaseHandle); |
| 289 | + } |
| 290 | + } |
| 291 | + |
| 292 | + /// <summary> |
| 293 | + /// |
| 294 | + /// </summary> |
| 295 | + /// <returns></returns> |
| 296 | + public virtual long GetTotalStepCount() |
| 297 | + { |
| 298 | + GitRebaseOptions gitRebaseOptions = new GitRebaseOptions() |
| 299 | + { |
| 300 | + version = 1, |
| 301 | + }; |
| 302 | + |
| 303 | + using (RebaseSafeHandle rebaseHandle = Proxy.git_rebase_open(repository.Handle, gitRebaseOptions)) |
| 304 | + { |
| 305 | + return Proxy.git_rebase_operation_entrycount(rebaseHandle); |
| 306 | + } |
| 307 | + } |
| 308 | + |
253 | 309 | private void EnsureNonBareRepo()
|
254 | 310 | {
|
255 | 311 | if (this.repository.Info.IsBare)
|
|
0 commit comments