ugit.types.ps1xml
<?xml version="1.0" encoding="utf-16"?> <!-- Generated with EZOut 1.9.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut --> <Types> <Type> <Name>git.branch</Name> <Members> <AliasProperty> <Name>HasUpstream</Name> <ReferencedMemberName>IsTracked</ReferencedMemberName> </AliasProperty> <ScriptMethod> <Name>Delete</Name> <Script> Push-Location $this.GitRoot git branch '-d' $this.BranchName @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>ToString</Name> <Script> $this.BranchName </Script> </ScriptMethod> <ScriptProperty> <Name>IsTracked</Name> <GetScriptBlock> Push-Location $this.GitRoot ( git remote | git remote show | Select-Object -ExpandProperty RemoteBranches | Where-Object BranchName -like "*$($this.BranchName)" ) -as [bool] Pop-Location </GetScriptBlock> </ScriptProperty> </Members> </Type> <Type> <Name>git.branch.detail</Name> <Members> <ScriptMethod> <Name>Delete</Name> <Script> Push-Location $this.GitRoot git branch '-d' $this.BranchName @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>ToString</Name> <Script> $this.BranchName </Script> </ScriptMethod> </Members> </Type> <Type> <Name>git.commit.info</Name> <Members> <ScriptMethod> <Name>Amend</Name> <Script> param( [Parameter(Mandatory)] [string] $Message ) Push-Location $this.GitRoot git commit --ammend -m $Message @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Push</Name> <Script> Push-Location $this.GitRoot git push @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>UpdateMessage</Name> <Script> param( [Parameter(Mandatory)] [string] $Message ) Push-Location $this.GitRoot git commit --ammend -m $Message @args Pop-Location </Script> </ScriptMethod> </Members> </Type> <Type> <Name>git.log</Name> <Members> <ScriptMethod> <Name>Archive</Name> <Script> param( [Parameter(Mandatory)] [string] $ArchivePath ) $unresolvedArchivePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($ArchivePath) Push-Location $this.GitRoot git archive $this.CommitHash '-o' "$unresolvedArchivePath" @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Checkout</Name> <Script> Push-Location $this.GitRoot git checkout $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Diff</Name> <Script> Push-Location $this.GitRoot $logPaths = @($this.GitCommand -split '\s' -notmatch '^(?>git|log)$' -notmatch '^\-' -ne '') Write-Debug "Logging paths: $logPaths" foreach ($logPath in $logPaths) { if (Test-Path $logPath) { $relativeArgs = @("--relative", $logPath) git diff $this.CommitHash @relativeArgs @args } } if (-not $logPaths) { Write-Debug "Getting diff of commit hash: $($this.CommitHash)" git diff $this.CommitHash @args } Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Reset</Name> <Script> Push-Location $this.GitRoot git reset $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Revert</Name> <Script> Push-Location $this.GitRoot git revert $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptProperty> <Name>ReferenceNumbers</Name> <GetScriptBlock> [Regex]::new("#(?<n>\d+)").Matches($this.CommitMessage) -replace '#' -as [int[]] </GetScriptBlock> </ScriptProperty> </Members> </Type> <Type> <Name>git.reference.log</Name> <Members> <AliasProperty> <Name>CommitHash</Name> <ReferencedMemberName>Hash</ReferencedMemberName> </AliasProperty> <ScriptMethod> <Name>Archive</Name> <Script> param( [Parameter(Mandatory)] [string] $ArchivePath ) $unresolvedArchivePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($ArchivePath) Push-Location $this.GitRoot git archive $this.CommitHash '-o' "$unresolvedArchivePath" @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Checkout</Name> <Script> Push-Location $this.GitRoot git checkout $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Diff</Name> <Script> Push-Location $this.GitRoot git diff $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Reset</Name> <Script> Push-Location $this.GitRoot git reset $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Revert</Name> <Script> Push-Location $this.GitRoot git revert $this.CommitHash @args Pop-Location </Script> </ScriptMethod> <ScriptProperty> <Name>ReferenceNumbers</Name> <GetScriptBlock> [Regex]::new("#(?<n>\d+)").Matches($this.CommitMessage) -replace '#' -as [int[]] </GetScriptBlock> </ScriptProperty> </Members> </Type> <Type> <Name>git.remote.name</Name> <Members> <ScriptMethod> <Name>ToString</Name> <Script> "$($this.RemoteName)" </Script> </ScriptMethod> </Members> </Type> <Type> <Name>git.stash.entry</Name> <Members> <ScriptMethod> <Name>Apply</Name> <Script> Push-Location $this.GitRoot git stash apply $this.Number Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Delete</Name> <Script> Push-Location $this.GitRoot git stash drop $this.Number Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Diff</Name> <Script> Push-Location $this.GitRoot git stash show $this.Number --patch Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Drop</Name> <Script> Push-Location $this.GitRoot git stash drop $this.Number Pop-Location </Script> </ScriptMethod> <ScriptMethod> <Name>Pop</Name> <Script> Push-Location $this.GitRoot git stash pop $this.Number Pop-Location </Script> </ScriptMethod> </Members> </Type> <Type> <Name>git.status</Name> <Members> <ScriptMethod> <Name>Push</Name> <Script> Push-Location $this.GitRoot if (-not $this.Status) { git push --set-upstream origin $this.BranchName @args } else { git push @args } Pop-Location </Script> </ScriptMethod> </Members> </Type> <Type> <Name>System.IO.FileInfo</Name> <Members> <AliasProperty> <Name>Changes</Name> <ReferencedMemberName>GitChanges</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>Diff</Name> <ReferencedMemberName>GitDiff</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>GitDifference</Name> <ReferencedMemberName>GitDiff</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>GitHistory</Name> <ReferencedMemberName>GitChanges</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>GitLog</Name> <ReferencedMemberName>GitLogs</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>HasChanged</Name> <ReferencedMemberName>GitDirty</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>HasChanges</Name> <ReferencedMemberName>GitDirty</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>History</Name> <ReferencedMemberName>GitChanges</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>IsUnstaged</Name> <ReferencedMemberName>GitDirty</ReferencedMemberName> </AliasProperty> <AliasProperty> <Name>Logs</Name> <ReferencedMemberName>GitLogs</ReferencedMemberName> </AliasProperty> <ScriptMethod> <Name>GitChanges</Name> <Script> <# .SYNOPSIS Get Changes for a given file .DESCRIPTION Gets changes from git for a given file. Can provide a timespan, series of numbers, date, or pair of dates. #> $byDate = @() $byNumber = @() $byTimespan = @() foreach ($arg in $args) { if ($arg -as [int] -ne $null) { $byNumber += $arg -as [int] } elseif ($arg -is [object[]]) { $byNumber += $arg } elseif ($arg -as [DateTime]) { $byDate+= $arg -as [DateTime] } elseif ( $arg -as [TimeSpan] ) { $byTimespan+= $arg -as [TimeSpan] } } Push-Location $this.Directory if ($byTimespan) { git log -Since ([DateTime]::Now - $byTimespan[0]) $this.Name } elseif ($byDate) { if ($byDate.Length -gt 1) { $first, $second = $byDate | Sort-Object git log -After $second -Before $first $this.Name } elseif ($byDate.Length -eq 1) { git log -Since $byDate[0] $this.Name } else { throw "Can only list Changes between two dates" } } elseif ($byNumber.Length) { $maxNumber = $byNumber | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum $maxNumber = $maxNumber + 1 $anyNegative = @($byNumber -lt 0).Length if ($anyNegative) { @(git log $this.Name)[@($byNumber -as [int[]])] } else { @(git log -n $maxNumber $this.Name)[@($byNumber -as [int[]])] } } else { git log $this.Name } Pop-Location </Script> </ScriptMethod> <ScriptProperty> <Name>GitDiff</Name> <GetScriptBlock> Push-Location $this.Directory (git log -n 1 $this.Name).Diff() Pop-Location </GetScriptBlock> </ScriptProperty> <ScriptProperty> <Name>GitDirty</Name> <GetScriptBlock> Push-Location $this.Directory $(git status $this.Name '-s') -as [bool] Pop-Location </GetScriptBlock> </ScriptProperty> <ScriptProperty> <Name>GitLogs</Name> <GetScriptBlock> Push-Location $this.Directory git log $this.Name Pop-Location </GetScriptBlock> </ScriptProperty> </Members> </Type> <Type> <Name>ugit.extension</Name> <Members> <ScriptProperty> <Name>Pattern</Name> <GetScriptBlock> foreach ($attr in $this.ScriptBlock.Attributes) { if ($attr -is [Management.Automation.ValidatePatternAttribute]) { $attr.RegexPattern } } </GetScriptBlock> </ScriptProperty> </Members> </Type> </Types> |