Functions/New-LibGit2SharpRebaseOptions.psm1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<# .SYNOPSIS Internal. Returns the options for LibGit2Sharp.Repository#Rebase(), shared by Start-, Stop- and Resume-GitRebase. #> function New-LibGit2SharpRebaseOptions { [CmdletBinding()] [OutputType([LibGit2Sharp.RebaseOptions])] param() $options = [LibGit2Sharp.RebaseOptions]::new() $options.OnCheckoutProgress = { param([string]$Path, [int]$CompletedSteps, [int]$TotalSteps) if ($ProgressPreference -ne 'SilentlyContinue' -and $TotalSteps -ne 0) { $progressParams = @{ Activity = 'Checking files out' } if ($TotalSteps -ne 0) { $progressParams.PercentComplete = (($CompletedSteps / $TotalSteps) * 100) } if ($Path) { $progressParams.Status = $Path } Write-Progress @progressParams } } $options.RebaseStepStarting = { param([LibGit2Sharp.BeforeRebaseStepInfo] $info) if ($ProgressPreference -ne 'SilentlyContinue') { Write-Progress ` -Activity 'Rebasing' ` -Status "$($info.StepIndex)/$($info.TotalStepCount)" ` -CurrentOperation "Applying $($info.StepInfo.Commit.Sha.Substring(0, 7)) $($info.StepInfo.Commit.MessageShort)" } } $options.RebaseStepCompleted = { param([LibGit2Sharp.AfterRebaseStepInfo] $info) if ($ProgressPreference -ne 'SilentlyContinue' -and $info.TotalStepCount -ne 0) { Write-Progress ` -Activity 'Rebasing' ` -PercentComplete (($info.StepIndex / $info.TotalStepCount) * 100) } # Write-Information "Applied $($info.StepInfo.Commit.Sha.Substring(0, 7)) $($info.StepInfo.Commit.MessageShort)" $info.StepInfo } return $options } Export-ModuleMember -Function New-LibGit2SharpRebaseOptions |