Skip to content

Instantly share code, notes, and snippets.

@shionryuu
Last active August 29, 2015 14:08
Show Gist options
  • Save shionryuu/87d875a31fe74e4757c9 to your computer and use it in GitHub Desktop.
Save shionryuu/87d875a31fe74e4757c9 to your computer and use it in GitHub Desktop.
use powershell to delete svn missing files

PowerShell 获取并删除svn丢失的文件

# recommended
function svn_missing
{
    svn status | where { $_ -match '\!\s*(?<x>\S*)' } | foreach { $matches.x }
    # or
    # svn status | where { $_ -match '\!\s*(?<x>\S*)' } | foreach { $matches['x'] }
    # or
    # svn status | ?{ $_ -match '\!\s*(?<x>\S*)' } | % { $matches['x'] }
}

function svn_missing2
{
    svn status | select-string -pattern '\!\s*(?<x>\S*)' | % {$null = $_ -match '!\s*(?<x>\S*)'; $matches.x}
    # or
    # svn status | select-string -pattern '\!\s*(?<x>\S*)' | %{$_.Matches[0].Groups[1].Value}
    # or
    # svn status | select-string -pattern '\!\s*(?<x>\S*)' | %{$_.Matches[0].Groups['x'].Value}
    # or
    # svn status | select-string -pattern '\!\s*(?<x>\S*)' | select -expand Matches | %{$_.groups['x'].value}
    # or
    # patt = '\!\s*(?<x>\S*)'
    # svn status | select-string -pattern $patt | %{[regex]::match($_, $patt).Groups['x'].Value}
}

# use powershell to delete svn missing files
svn_missing | % {svn del $_}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment