-
Notifications
You must be signed in to change notification settings - Fork 29
/
Get-Todos.ps1
30 lines (26 loc) · 1.03 KB
/
Get-Todos.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<#
.SYNOPSIS
Returns the TODOs for the current git repo, which can help document technical debt.
.EXAMPLE
Get-Todos.ps1 |Out-GridView -Title "$((Get-Item $(git rev-parse --show-toplevel)).Name) TODOs"
Shows TODOs in this repo.
#>
#Requires -Version 7
[CmdletBinding()] Param()
Push-Location $(git rev-parse --show-toplevel)
Find-Lines.ps1 -Pattern '\bTODO\b' -Filters * -Path ((Test-Path src -Type Container) ? 'src' : '.') -CaseSensitive |
ForEach-Object {
[string[]] $blame = git blame -p -L "$($_.LineNumber),$($_.LineNumber)" -- $_.Path
$author = $blame |Select-String '^author (?<Author>.*)$' |Select-CapturesFromMatches.ps1 -ValuesOnly
$Time = $blame |Select-String '^author-time (?<Time>.*)$' |Select-CapturesFromMatches.ps1 -ValuesOnly |
ConvertFrom-EpochTime.ps1
[pscustomobject]@{
Author = $author
Time = $time
Todo = ($_.Line -split 'TODO:?\s*',2)[1].Trim()
Path = Resolve-Path $_.Path -Relative
LineNumber = $_.LineNumber
}
} |
Sort-Object Time -Descending
Pop-Location