Created
October 28, 2013 13:23
-
-
Save jernejg/7196705 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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