Skip to content

Commit

Permalink
Merge pull request #120 from StartAutomating/ugit-pipeline-improvement
Browse files Browse the repository at this point in the history
ugit 0.3.5
  • Loading branch information
StartAutomating committed Feb 5, 2023
2 parents 74d33e7 + 9a900b3 commit 4de6bfc
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 27 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.3.5:

* Use-Git: Fixing pipeline behavior for non-file input (Fixes #119)
* Git.log: Attaching .GitCommand, not .GitArgument (Fixes #118)
* Git.mv: Reducing liklihood of errors in directory moves (Fixes #117)

---

## 0.3.4:

* Improving pipeling behavior (Fixes #110)
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Git.Log.UGit.Extension.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ param(
)

begin {
# TODO: Support git log --shortstat (#102)
# TODO: Support git log trailers (#112)
$script:LogChangesMerged = $false
$Git_Log = [Regex]::new(@'
(?m)^commit # Commits start with 'commit'
Expand Down Expand Up @@ -72,7 +74,7 @@ begin {
$gitLogMatch = $Git_Log.Match($OutputLines -join [Environment]::NewLine)
if (-not $gitLogMatch.Success) { return }

$gitLogOut = [Ordered]@{PSTypeName='git.log';GitArgument=$gitArgument}
$gitLogOut = [Ordered]@{PSTypeName='git.log';GitCommand=$gitCommand}
if ($gitCommand -like '*--merges*') {
$gitLogOut.PSTypeName = 'git.merge.log'
}
Expand Down
1 change: 0 additions & 1 deletion Extensions/Git.Mv.UGit.Extension.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ end {

$destItem = Get-Item $dest -ErrorAction SilentlyContinue
@(if ($destItem -is [IO.DirectoryInfo]) {
$destItem = Get-Item (Join-Path $destItem $source)
$destItem
} elseif ($destItem) {
$destItem
Expand Down
95 changes: 74 additions & 21 deletions Get-UGitExtension.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
#region Piecemeal [ 0.3.8 ] : Easy Extensible Plugins for PowerShell
# Install-Module Piecemeal -Scope CurrentUser
# Import-Module Piecemeal -Force
# Install-Piecemeal -ExtensionModule 'ugit' -ExtensionModuleAlias 'git' -ExtensionNoun 'UGitExtension' -ExtensionTypeName 'ugit.extension' -OutputPath '.\Get-UGitExtension.ps1'
Expand Down Expand Up @@ -231,6 +231,7 @@ function Get-UGitExtension
$ExecutionContext.SessionState.InvokeCommand.GetCommand($in, 'Function,ExternalScript,Application')
}

#region .GetExtendedCommands
$extCmd.PSObject.Methods.Add([psscriptmethod]::new('GetExtendedCommands', {
param([Management.Automation.CommandInfo[]]$CommandList)
$extendedCommandNames = @(
Expand Down Expand Up @@ -266,7 +267,8 @@ function Get-UGitExtension

$this | Add-Member NoteProperty Extends $extends.Keys -Force
$this | Add-Member NoteProperty ExtensionCommands $extends.Values -Force
}))
}), $true)
#endregion .GetExtendedCommands

if (-not $script:AllCommands) {
$script:AllCommands = $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function,Alias,Cmdlet', $true)
Expand All @@ -277,6 +279,7 @@ function Get-UGitExtension

$inheritanceLevel = [ComponentModel.InheritanceLevel]::Inherited

#region .BlockComments
$extCmd.PSObject.Properties.Add([psscriptproperty]::New('BlockComments', {
[Regex]::New("
\<\# # The opening tag
Expand All @@ -285,8 +288,10 @@ function Get-UGitExtension
)
\#\> # the closing tag
", 'IgnoreCase,IgnorePatternWhitespace', '00:00:01').Matches($this.ScriptBlock)
}))
}), $true)
#endregion .BlockComments

#region .GetHelpField
$extCmd.PSObject.Methods.Add([psscriptmethod]::New('GetHelpField', {
param([Parameter(Mandatory)]$Field)
$fieldNames = 'synopsis','description','link','example','inputs', 'outputs', 'parameter', 'notes'
Expand All @@ -307,17 +312,26 @@ function Get-UGitExtension
$match.Groups["Content"].Value -replace '[\s\r\n]+$'
}
}
}))
}), $true)
#endregion .GetHelpField

$extCmd.PSObject.Properties.Add([PSNoteProperty]::new('InheritanceLevel', $inheritanceLevel))
#region .InheritanceLevel
$extCmd.PSObject.Properties.Add([PSNoteProperty]::new('InheritanceLevel', $inheritanceLevel), $true)
#endregion .InheritanceLevel

#region .DisplayName
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'DisplayName', [ScriptBlock]::Create("`$this.Name -replace '$extensionFullRegex'")
))
), $true)
#endregion .DisplayName

#region .Attributes
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Attributes', {$this.ScriptBlock.Attributes}
))

), $true)
#endregion .Attributes

#region .Category
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Category', {
foreach ($attr in $this.ScriptBlock.Attributes) {
Expand All @@ -331,8 +345,10 @@ function Get-UGitExtension
}

}
))
), $true)
#endregion .Category

#region .Rank
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Rank', {
foreach ($attr in $this.ScriptBlock.Attributes) {
Expand All @@ -343,8 +359,10 @@ function Get-UGitExtension
}
return 0
}
))
), $true)
#endregion .Rank

#region .Metadata
$extCmd.PSObject.Properties.Add([psscriptproperty]::new(
'Metadata', {
$Metadata = [Ordered]@{}
Expand All @@ -359,21 +377,32 @@ function Get-UGitExtension
}
return $Metadata
}
))
), $true)
#endregion .Metadata

#region .Description
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Description', { @($this.GetHelpField("Description"))[0] -replace '^\s+' }
))
), $true)
#endregion .Description

#region .Synopsis
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Synopsis', { @($this.GetHelpField("Synopsis"))[0] -replace '^\s+' }))
'Synopsis', { @($this.GetHelpField("Synopsis"))[0] -replace '^\s+' }), $true)
#endregion .Synopsis

#region .Examples
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Examples', { $this.GetHelpField("Example") }))
'Examples', { $this.GetHelpField("Example") }), $true)
#endregion .Examples

#region .Links
$extCmd.PSObject.Properties.Add([PSScriptProperty]::new(
'Links', { $this.GetHelpField("Link") }))
'Links', { $this.GetHelpField("Link") }), $true
)
#endregion .Links

#region .Validate
$extCmd.PSObject.Methods.Add([psscriptmethod]::new('Validate', {
param(
# input being validated
Expand Down Expand Up @@ -463,8 +492,25 @@ function Get-UGitExtension
} else {
return $false
}
}))
}), $true)
#endregion .Validate

#region .HasValidation
$extCmd.PSObject.Properties.Add([psscriptproperty]::new('HasValidation', {
foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -is [Management.Automation.ValidateScriptAttribute] -or
$attr -is [Management.Automation.ValidateSetAttribute] -or
$attr -is [Management.Automation.ValidatePatternAttribute] -or
$attr -is [Management.Automation.ValidateRangeAttribute]) {
return $true
}
}

return $false
}), $true)
#endregion .HasValidation

#region .GetDynamicParameters
$extCmd.PSObject.Methods.Add([PSScriptMethod]::new('GetDynamicParameters', {
param(
[string]
Expand Down Expand Up @@ -560,9 +606,11 @@ function Get-UGitExtension

$ExtensionDynamicParameters

}))
}), $true)
#endregion .GetDynamicParameters


#region .IsParameterValid
$extCmd.PSObject.Methods.Add([PSScriptMethod]::new('IsParameterValid', {
param([Parameter(Mandatory)]$ParameterName, [PSObject]$Value)

Expand Down Expand Up @@ -594,8 +642,10 @@ function Get-UGitExtension
}
}
return $true
}))
}), $true)
#endregion .IsParameterValid

#region .CouldPipe
$extCmd.PSObject.Methods.Add([PSScriptMethod]::new('CouldPipe', {
param([PSObject]$InputObject)

Expand Down Expand Up @@ -642,8 +692,10 @@ function Get-UGitExtension
return $mappedParams
}
}
}))
}), $true)
#endregion .CouldPipe

#region .CouldRun
$extCmd.PSObject.Methods.Add([PSScriptMethod]::new('CouldRun', {
param([Collections.IDictionary]$params, [string]$ParameterSetName)

Expand Down Expand Up @@ -682,7 +734,8 @@ function Get-UGitExtension
return $mappedParams
}
return $false
}))
}), $true)
#endregion .CouldRun

$extCmd.pstypenames.clear()
if ($UGitExtensionTypeName) {
Expand Down Expand Up @@ -936,5 +989,5 @@ function Get-UGitExtension
}
}
}
#endregion Piecemeal [ 0.3.7 ] : Easy Extensible Plugins for PowerShell
#endregion Piecemeal [ 0.3.8 ] : Easy Extensible Plugins for PowerShell

15 changes: 12 additions & 3 deletions Use-Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,22 @@
# If there was piped in input
if ($InputObject) {
$AllInputObjects += $InputObject # accumulate it.
}
}
}

end {
# First, we need to take any input and figure out what directories we are going into.
$directories = @()
#
# Next, we need to create a collection of input object from each directory.
$InputDirectories = [Ordered]@{}


if (
$AllInputObjects.Length -eq 0 -and # If we had no input objects and
$myInv.PipelinePosition -gt 1 # are not the first step in the pipeline,
) {
return # we're done.
}

$inputObject =
@(foreach ($in in $AllInputObjects) {
Expand Down Expand Up @@ -153,7 +161,7 @@
$InputDirectories[$directories[-1]] =
# by forcing an existing entry into a list
@($InputDirectories[$directories[-1]]) +
$in.Fullname # and adding this file name.
$in # and adding this item.
}
}
}
Expand Down Expand Up @@ -203,6 +211,7 @@
}

foreach ($inObject in $InputDirectories[$dir]) {
if (-not $inObject -and $myInv.PipelinePosition -gt 1) { continue }
$AllGitArgs = @(@($GitArgument) + $inObject) # Then we collect the combined arguments
$AllGitArgs = @($AllGitArgs -ne '') # (skipping any empty arguments)
$OutGitParams = @{GitArgument=$AllGitArgs} # and prepare a splat (to save precious space when reporting errors).
Expand Down
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.3.5:

* Use-Git: Fixing pipeline behavior for non-file input (Fixes #119)
* Git.log: Attaching .GitCommand, not .GitArgument (Fixes #118)
* Git.mv: Reducing liklihood of errors in directory moves (Fixes #117)

---

## 0.3.4:

* Improving pipeling behavior (Fixes #110)
Expand Down
10 changes: 9 additions & 1 deletion ugit.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
ModuleVersion = '0.3.4'
ModuleVersion = '0.3.5'
RootModule = 'ugit.psm1'
FormatsToProcess = 'ugit.format.ps1xml'
TypesToProcess = 'ugit.types.ps1xml'
Expand All @@ -17,6 +17,14 @@ PrivateData = @{
LicenseURI = 'https://github.com/StartAutomating/ugit/blob/main/LICENSE'
BuildModule = @('EZOut', 'Piecemeal', 'PipeScript')
ReleaseNotes = @'
## 0.3.5:
* Use-Git: Fixing pipeline behavior for non-file input (Fixes #119)
* Git.log: Attaching .GitCommand, not .GitArgument (Fixes #118)
* Git.mv: Reducing liklihood of errors in directory moves (Fixes #117)
---
## 0.3.4:
* Improving pipeling behavior (Fixes #110)
Expand Down

0 comments on commit 4de6bfc

Please sign in to comment.