Skip to content

Commit

Permalink
Publish-GitPubJekyll: Fixing date handling (Fixes #51)
Browse files Browse the repository at this point in the history
  • Loading branch information
StartAutomating authored and StartAutomating committed Oct 25, 2022
1 parent 77f44d5 commit e39a8d3
Showing 1 changed file with 52 additions and 12 deletions.
64 changes: 52 additions & 12 deletions Get-GitPub.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,38 @@ $executionContext.SessionState.InvokeCommand.GetCommands('*','Function',$true)
)
# 'unroll' the collection by iterating over it once.
$filteredCollection = $inputCollection =
@(foreach ($in in $inputCollection) { $in })
@(foreach ($in in $inputCollection) {
$in
})
# Since filtering conditions have been passed, we must filter item-by-item
$filteredCollection = foreach ($item in $inputCollection) {
$filteredCollection = :nextItem foreach ($item in $inputCollection) {
# we set $this, $psItem, and $_ for ease-of-use.
$this = $_ = $psItem = $item

# Some of the items may be variables.
if ($item -is [Management.Automation.PSVariable]) {
# In this case, reassign them to their value.
$this = $_ = $psItem = $item = $item.Value
}

if (-not $(
# Some of the items may be enumerables
$unrolledItems =
if ($item.GetEnumerator -and $item -isnot [string]) {
@($item.GetEnumerator())
} else {
$item
}
foreach ($item in $unrolledItems) {
$this = $_ = $psItem = $item
if (-not $(
foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -is [Reflection.AssemblyMetaDataAttribute] -and $attr.Key -eq 'GitPub.Source') { $true; break }
}
)) { continue }
$item
)) { continue }
$item
}


}
# Walk over each item in the filtered collection
foreach ($item in $filteredCollection) {
Expand All @@ -46,8 +66,8 @@ if ($item.value -and $item.value.pstypenames.insert) {
elseif ($item.pstypenames.insert -and $item.pstypenames -notcontains 'GitPub.Sources') {
$item.pstypenames.insert(0, 'GitPub.Sources')
}

$item

}
)

Expand All @@ -59,19 +79,39 @@ $executionContext.SessionState.InvokeCommand.GetCommands('*','Function',$true)
)
# 'unroll' the collection by iterating over it once.
$filteredCollection = $inputCollection =
@(foreach ($in in $inputCollection) { $in })
@(foreach ($in in $inputCollection) {
$in
})
# Since filtering conditions have been passed, we must filter item-by-item
$filteredCollection = foreach ($item in $inputCollection) {
$filteredCollection = :nextItem foreach ($item in $inputCollection) {
# we set $this, $psItem, and $_ for ease-of-use.
$this = $_ = $psItem = $item

# Some of the items may be variables.
if ($item -is [Management.Automation.PSVariable]) {
# In this case, reassign them to their value.
$this = $_ = $psItem = $item = $item.Value
}

if (-not $(
# Some of the items may be enumerables
$unrolledItems =
if ($item.GetEnumerator -and $item -isnot [string]) {
@($item.GetEnumerator())
} else {
$item
}
foreach ($item in $unrolledItems) {
$this = $_ = $psItem = $item
if (-not $(
foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -is [Reflection.AssemblyMetaDataAttribute] -and
($attr.Key -eq 'GitPub.Publisher')) { $true; break }
}
)) { continue }
$item
)) { continue }
$item
}


}
# Walk over each item in the filtered collection
foreach ($item in $filteredCollection) {
Expand All @@ -85,8 +125,8 @@ if ($item.value -and $item.value.pstypenames.insert) {
elseif ($item.pstypenames.insert -and $item.pstypenames -notcontains 'GitPub.Publishers') {
$item.pstypenames.insert(0, 'GitPub.Publishers')
}

$item

}
)
[PSCustomObject]@{
Expand Down

0 comments on commit e39a8d3

Please sign in to comment.