Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $deletedFiles = @(git ls-files --deleted)
- if($deletedFiles.length -ne 0) {
- $deletedFiles | % { git rm $_ }
- git commit -m "Deleted some files"
- }
- $f = git status --porcelain=v1 -u
- if(!$?) { throw "Failed." }
- $f = $f | % { $_ -replace '^...', '' -replace '^"', '' -replace '"$', '' }
- $f = $f | % { ls -Force -LiteralPath $_ } | sort FullName
- function BuildCommands($batch) {
- @($batch) | % {
- git add $_
- }
- git commit -m 'Adding new batch'
- git push
- if(!$?) {
- throw "Failed to push batch."
- }
- }
- $maxSize = 500MB
- $totalSize = 0
- $thisBatch = New-Object System.Collections.ArrayList
- $commands = for($i = 0; $i -ne $f.length; ++$i) {
- $current = $f[$i]
- Write-Host $current.FullName
- $currentSize = $current.Length
- $sizeIncludingThis = $totalSize + $currentSize
- if($sizeIncludingThis -le $maxSize) {
- $thisBatch.Add($current) | Out-Null
- $totalSize = $sizeIncludingThis
- if($i -eq $f.length - 1) {
- # this is the final batch of stragglers
- BuildCommands $thisBatch
- }
- } else {
- if($thisBatch.Count -ne 0) {
- BuildCommands $thisBatch
- }
- $thisBatch = New-Object System.Collections.ArrayList
- $thisBatch.Add($current) | Out-Null
- $totalSize = $currentSize
- }
- }
Add Comment
Please, Sign In to add comment