Commit c7ffc918 authored by Dustin Howett's avatar Dustin Howett

gcf: make include/exclude actually work+filter status first

parent 7cacc3cc
......@@ -49,39 +49,38 @@ Function Coalesce-Status {
If ([String]::IsNullOrEmpty($_)) { Return }
$line = $_
$filename, $renamedOrCopiedFrom = $Null, $Null
$inidx = Convert-GitStatusCharacter([char]($line[2]))
$workt = Convert-GitStatusCharacter([char]($line[3]))
Switch ($line[0]) {
"1" { $filename = $line.Split(" ", 9)[8] }
"2" {
$filename, $renamedOrCopiedFrom = $line.Split(" ", 10)[9].Split("`t", 2)
}
"?" { Return }
default {
Write-Warning "Unexpected git status type $($line[0])."
Return
If (($inidx -Ne [GitFileStatus]::None -And $Source -Ne "Worktree") -Or
($workt -Ne [GitFileStatus]::None -And $Source -Ne "Index")) {
Switch ($line[0]) {
"1" { $filename = $line.Split(" ", 9)[8] }
"2" {
$filename, $renamedOrCopiedFrom = $line.Split(" ", 10)[9].Split("`t", 2)
}
"?" { Return }
default {
Write-Warning "Unexpected git status type $($line[0])."
Return
}
}
}
If (![String]::IsNullOrEmpty($Filter) -And $filename -NotLike $Filter) {
Return
}
ForEach ($i in $Exclude) {
If ($filename -Like $i) {
$nameonly = Split-Path -Leaf $filename
If (![String]::IsNullOrEmpty($Filter) -And $nameonly -NotLike $Filter) {
Return
}
}
ForEach ($i in $Include) {
If ($filename -NotLike $i) {
Return
ForEach ($i in $Exclude) {
If ($nameonly -Like $i) { Return }
}
$inc = $Include.Length -Eq 0 # no includes = always include
ForEach ($i in $Include) {
If ($inc = $inc -Or ($nameonly -Like $i)) { Break }
}
}
$inidx = Convert-GitStatusCharacter([char]($line[2]))
$workt = Convert-GitStatusCharacter([char]($line[3]))
If (($inidx -Ne [GitFileStatus]::None -And $Source -Ne "Worktree") -Or
($workt -Ne [GitFileStatus]::None -And $Source -Ne "Index")) {
If (-Not $inc) { Return }
Get-Item $filename | Add-Member -PassThru -NotePropertyMembers @{
Status = (Coalesce-Status $workt, $inidx);
OriginalFile = $renamedOrCopiedFrom;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment