forked from stcu/SharedScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Todos.ps1
29 lines (25 loc) · 1022 Bytes
/
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
<#
.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 3
[CmdletBinding()] Param()
Push-Location $(git rev-parse --show-toplevel)
Find-Lines.ps1 TODO * src -Simple -CaseSensitive |
foreach {
$blame = git blame -p -L "$($_.LineNumber),$($_.LineNumber)" -- $_.Path
$author = $blame |where {$_ -match '^author (?<Author>.*)$'} |foreach {$Matches.Author}
$Time = $blame |where {$_ -match '^author-time (?<Time>.*)$'} |foreach {(Get-Date 1970-01-01).AddSeconds([int]$Matches.Time)}
[pscustomobject]@{
Author = $author
Time = $time
Todo = ($_.Line -split 'TODO:?\s*',2)[1].Trim()
Path = Resolve-Path $_.Path -Relative
LineNumber = $_.LineNumber
}
} |
sort Time -Descending
Pop-Location