Closed majkinetor closed 3 years ago
Function to get such file:
function Get-GitRevisionDates($Path='.', $Ext, $Skip)
{
[array] $log = git --no-pager log --format=format:%ai --name-only $Path
$date_re = "^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d .\d{4}$"
[array] $dates = $log | Select-String $date_re | select LineNumber, Line
$files = $log -notmatch "^$date_re$" | ? {
if (!$_.EndsWith($Ext)) { return }
foreach ($s in $Skip) { if ($_ -like $s) { return } }
$_
} | sort -unique
$res = @()
foreach ($file in $files) {
$iFile = $log.IndexOf($file) + 1
$fDate = $dates | ? LineNumber -lt $iFile | select -Last 1
$res += [PSCustomObject]@{ File = $file; Date = $fDate.Line }
}
$res | sort Date -Desc
}
Implemented:
The current plugin https://github.com/zhaoterryy/mkdocs-git-revision-date-plugin seems problematic because it requires git to be present during build which might not be general case and also it might be on monorepo which makes paths different then those during build.
Idea is to export dates before the build for all included files and make a plugin that consults this file.