ugit.types.ps1xml

<?xml version="1.0" encoding="utf-16"?>
<!-- Generated with EZOut 2.0.6: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<Types>
  <Type>
    <Name>git.blame</Name>
    <Members>
      <ScriptProperty>
        <Name>Log</Name>
        <GetScriptBlock>
                        
Push-Location $this.GitRoot
git log $this.CommitHash -NumberOfCommits 1
Pop-Location
                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.branch</Name>
    <Members>
      <AliasProperty>
        <Name>Compare</Name>
        <ReferencedMemberName>Diff</ReferencedMemberName>
      </AliasProperty>
      <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>Diff</Name>
        <Script>
                        param()

$firstArg, $restOfArgs =
if (-not $args) {
    git remote | git remote show | Select-Object -ExpandProperty HeadBranch -First 1
} else {
    $args | Select-Object -First 1
    $args | Select-Object -Skip 1
}

$restOfArgs = @($restOfArgs)

Push-Location $this.GitRoot
git diff "$($firstArg)..$($this.BranchName)" @restOfArgs
Pop-Location
                    </Script>
      </ScriptMethod>
      <ScriptMethod>
        <Name>Rename</Name>
        <Script>
                        if (-not $args) {
    throw "Must provide a new branch name"
}
Push-Location $this.GitRoot
git branch '-m' $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.checkout</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.clone</Name>
    <Members>
      <ScriptMethod>
        <Name>ToString</Name>
        <Script>
                        $this.Directory.ToString()

                    </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.diff</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.error</Name>
    <Members>
      <ScriptProperty>
        <Name>UnknownRevision</Name>
        <GetScriptBlock>
                        &lt;#
.SYNOPSIS
    Gets Unknown Revisions
.DESCRIPTION
    Gets Unknown Revisions from any git error output.
#&gt;
if ($this -match "'(?&lt;n&gt;.+?)'\: unknown revision or path not in the working tree") {
    $matches.n
}
                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.grep</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.init</Name>
    <Members>
    </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 '^(?&gt;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("#(?&lt;n&gt;\d+)").Matches($this.CommitMessage) -replace '#' -as [int[]]
                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.merge.error</Name>
    <Members>
      <ScriptProperty>
        <Name>Conflict</Name>
        <GetScriptBlock>
                        &lt;#
.SYNOPSIS
    Gets Conflicts
.DESCRIPTION
    Gets Conflicts from any git merge output.
#&gt;
foreach ($line in $this -split '[\r\n]+') {
    if ($line -match "^\t(?&lt;path&gt;.+?)\s{0,}$") {
        $matches.path
    }
}


                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.output</Name>
    <Members>
      <ScriptProperty>
        <Name>NotGitCommand</Name>
        <GetScriptBlock>
                        &lt;#
.SYNOPSIS
    Gets what was not a Git Command
.DESCRIPTION
    If the git output is not a git command, this will output the command name.
#&gt;
if ($this -match "^git:\s'(?&lt;cmd&gt;.+?)' is not a git command.") {
    return $matches.cmd
}
                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.pull</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.pull.error</Name>
    <Members>
      <ScriptProperty>
        <Name>Conflict</Name>
        <GetScriptBlock>
                        &lt;#
.SYNOPSIS
    Gets Conflicts
.DESCRIPTION
    Gets Conflicts from any git pull output.
#&gt;
foreach ($line in $this -split '[\r\n]+') {
    if ($line -match "^\t(?&lt;path&gt;.+?)\s{0,}$") {
        $matches.path
    }
}


                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.push</Name>
    <Members>
    </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("#(?&lt;n&gt;\d+)").Matches($this.CommitMessage) -replace '#' -as [int[]]
                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>git.remote</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.remote.name</Name>
    <Members>
      <ScriptMethod>
        <Name>ToString</Name>
        <Script>
                        "$($this.RemoteName)"
                    </Script>
      </ScriptMethod>
    </Members>
  </Type>
  <Type>
    <Name>git.removal</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.shortlog</Name>
    <Members>
    </Members>
  </Type>
  <Type>
    <Name>git.stash</Name>
    <Members>
    </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>git.submodule</Name>
    <Members>
    </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>
                        &lt;#
.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.
#&gt;

$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</Name>
    <Members>
      <AliasProperty>
        <Name>ConventionalCommits</Name>
        <ReferencedMemberName>ConventionalCommit</ReferencedMemberName>
      </AliasProperty>
      <ScriptProperty>
        <Name>ConventionalCommit</Name>
        <GetScriptBlock>
                        if (-not $this.'.ConventionalCommits') {
    $this | Add-Member NoteProperty '.ConventionalCommits' ([PSCustomObject]@{
        PSTypeName = 'ugit.Conventional.Commit'
    })
}

$this.'.ConventionalCommits'

                    </GetScriptBlock>
      </ScriptProperty>
    </Members>
  </Type>
  <Type>
    <Name>ugit.Conventional.Commit</Name>
    <Members>
      <AliasProperty>
        <Name>Types</Name>
        <ReferencedMemberName>Type</ReferencedMemberName>
      </AliasProperty>
      <ScriptProperty>
        <Name>Type</Name>
        <GetScriptBlock>
                        &lt;#
.SYNOPSIS
    Gets Conventional Commit Types
.DESCRIPTION
    Gets the different types of Conventional Commits
.EXAMPLE
    $ugit.ConventionalCommit.Type
.LINK
    https://www.conventionalcommits.org/en/v1.0.0/#specification
#&gt;
param()

if (-not $this.'.Types') {
    $this | Add-Member NoteProperty '.Types' @(
        "feat" # feature
        "fix" # bugfix
        "build" # build related
        "chore" # chore / code housekeeping
        "ci" # ci
        "docs" # documentation
        "style" # stylistic
        "refactor" # refactoring
        "release" # releasing
        "perf" # performance improvement
        "test" # tests
        "BREAKING CHANGE" # BREAKING CHANGES
    ) -Force
}
$this.'.Types'

                    </GetScriptBlock>
        <SetScriptBlock>
                        param()

$unrolledArgs = @($args | . { process { $_ }})

$standardTypes = @(
    "feat" # feature
    "fix" # bugfix
    "build" # build related
    "chore" # chore / code housekeeping
    "ci" # ci
    "docs" # documentation
    "style" # stylistic
    "refactor" # refactoring
    "release" # releasing
    "perf" # performance improvement
    "test" # tests
    "BREAKING CHANGE" # BREAKING CHANGES
)

$combinedTypes = @(@($unrolledArgs + $standardTypes) | Select-Object -Unique)

$this | Add-Member NoteProperty '.Types' $combinedTypes -Force

                    </SetScriptBlock>
      </ScriptProperty>
      <NoteProperty>
        <Name>README</Name>
        <Value>Conventional Commits are a useful way to organize your commit messages in Git.

To learn more about them, visit:

https://www.conventionalcommits.org/

ugit makes them a little easier to work with.

In ugit, `git commit` supports a virtual parameter `-Type`.

You can tab thru any conventional commit types until you find the right one.</Value>
      </NoteProperty>
    </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>