private static RebaseStepResult ApplyPickStep(RebaseHandle rebaseOperationHandle, Repository repository, Identity committer, RebaseOptions options, RebaseStepInfo stepToApplyInfo) { RebaseStepResult rebaseStepResult; // commit and continue. if (repository.Index.IsFullyMerged) { Proxy.GitRebaseCommitResult rebase_commit_result = Proxy.git_rebase_commit(rebaseOperationHandle, null, committer); if (rebase_commit_result.WasPatchAlreadyApplied) { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.ChangesAlreadyApplied); } else { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.Committed, rebase_commit_result.CommitId); } } else { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.Conflicts); } return(rebaseStepResult); }
private static RebaseStepResult ApplyPickStep(RebaseHandle rebaseOperationHandle, Repository repository, Identity committer, RebaseOptions options, RebaseStepInfo stepToApplyInfo) { RebaseStepResult rebaseStepResult; // commit and continue. if (repository.Index.IsFullyMerged) { Proxy.GitRebaseCommitResult rebase_commit_result = Proxy.git_rebase_commit(rebaseOperationHandle, null, committer); if (rebase_commit_result.WasPatchAlreadyApplied) { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.ChangesAlreadyApplied); } else { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.Committed, rebase_commit_result.CommitId); } } else { rebaseStepResult = new RebaseStepResult(RebaseStepStatus.Conflicts); } return rebaseStepResult; }
/// <summary> /// Run the current rebase step. This will handle reporting that we are about to run a rebase step, /// identifying and running the operation for the current step, and reporting the current step is completed. /// </summary> /// <param name="rebaseOperationHandle"></param> /// <param name="repository"></param> /// <param name="committer"></param> /// <param name="options"></param> /// <param name="stepToApplyIndex"></param> /// <param name="totalStepCount"/> /// <returns></returns> private static unsafe RebaseResult RunRebaseStep(RebaseHandle rebaseOperationHandle, Repository repository, Identity committer, RebaseOptions options, long stepToApplyIndex, long totalStepCount) { RebaseStepResult rebaseStepResult = null; RebaseResult rebaseSequenceResult = null; git_rebase_operation *rebaseOp = Proxy.git_rebase_operation_byindex(rebaseOperationHandle, stepToApplyIndex); ObjectId idOfCommitBeingRebased = ObjectId.BuildFromPtr(&rebaseOp->id); RebaseStepInfo stepToApplyInfo = new RebaseStepInfo(rebaseOp->type, repository.Lookup <Commit>(idOfCommitBeingRebased), LaxUtf8NoCleanupMarshaler.FromNative(rebaseOp->exec)); // Report the rebase step we are about to perform. if (options.RebaseStepStarting != null) { options.RebaseStepStarting(new BeforeRebaseStepInfo(stepToApplyInfo, stepToApplyIndex, totalStepCount)); } // Perform the rebase step git_rebase_operation *rebaseOpReport = Proxy.git_rebase_next(rebaseOperationHandle); // Verify that the information from the native library is consistent. VerifyRebaseOp(rebaseOpReport, stepToApplyInfo); // Handle the result switch (stepToApplyInfo.Type) { case RebaseStepOperation.Pick: rebaseStepResult = ApplyPickStep(rebaseOperationHandle, repository, committer, options, stepToApplyInfo); break; case RebaseStepOperation.Squash: case RebaseStepOperation.Edit: // case RebaseStepOperation.Exec: case RebaseStepOperation.Fixup: case RebaseStepOperation.Reword: // These operations are not yet supported by lg2. throw new GitException("Rebase Operation Type ({0}) is not currently supported in Simula.Scripting.Git.", stepToApplyInfo.Type); default: throw new ArgumentException(string.Format( "Unexpected Rebase Operation Type: {0}", stepToApplyInfo.Type)); } // Report that we just completed the step if (options.RebaseStepCompleted != null && (rebaseStepResult.Status == RebaseStepStatus.Committed || rebaseStepResult.Status == RebaseStepStatus.ChangesAlreadyApplied)) { if (rebaseStepResult.ChangesAlreadyApplied) { options.RebaseStepCompleted(new AfterRebaseStepInfo(stepToApplyInfo, stepToApplyIndex, totalStepCount)); } else { options.RebaseStepCompleted(new AfterRebaseStepInfo(stepToApplyInfo, repository.Lookup <Commit>(new ObjectId(rebaseStepResult.CommitId)), stepToApplyIndex, totalStepCount)); } } // If the result of the rebase step is something that requires us to stop // running the rebase sequence operations, then report the result. if (rebaseStepResult.Status == RebaseStepStatus.Conflicts) { rebaseSequenceResult = new RebaseResult(RebaseStatus.Conflicts, stepToApplyIndex, totalStepCount, null); } return(rebaseSequenceResult); }