Skip to content

Instantly share code, notes, and snippets.

@jernejg
Created October 28, 2013 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jernejg/7196705 to your computer and use it in GitHub Desktop.
Save jernejg/7196705 to your computer and use it in GitHub Desktop.
[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