Instantly share code, notes, and snippets.

Embed
What would you like to do?
[system.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");
function Get-HgAddedLargeFile
{
process
{
return ForEach-Object {$_.Insert(1,",").Remove(2,1)} `
| ConvertFrom-Csv -Header Status,Path `
| Where-Object {$_.Status -ieq "A"} `
| Get-Item `
| Where-Object {$_.Length -gt 1MB}
}
}
function Show-MessageBox($largeFiles)
{
$buttons=[system.windows.forms.messageboxbuttons]::YesNo
$icon =[System.Windows.Forms.MessageBoxIcon]::Warning
$title = "Some files are to large to comit!"
[System.Windows.Forms.MessageBox]::Show($largeFiles + "`r`n Commit anyway?","$title",$buttons,$icon)
}
Set-Location (Get-Childitem Env:HG_PENDING).Value
$largeFilesCount = (hg status `
| Get-HgAddedLargeFile `
| measure).Count
if ($largeFilesCount -gt 0)
{
$files = hg status | Get-HgAddedLargeFile | Out-String
$a = Show-MessageBox($files)
if ($a -eq "Yes")
{
$largeFilesCount = 0
}
}
exit $largeFilesCount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment