Skip to content

Instantly share code, notes, and snippets.

@abombss
Last active December 15, 2015 11:49
Show Gist options
  • Save abombss/5255607 to your computer and use it in GitHub Desktop.
Save abombss/5255607 to your computer and use it in GitHub Desktop.
Add-GitIgnore
function Add-GitIgnoreForVS ([switch]$DisableNugetRestore,[switch]$PassThru) {
$cmdArgs = @{
Name="VisualStudio"
PassThru=$PassThru
Uncomment=( & {if($DisableNugetRestore) { @() } else { @("packages/") } })
}
Add-GitIgnore @cmdArgs
}
function Add-GitIgnore ([string]$Name, [switch]$PassThru, [string]$UserRepo="github/gitignore", [string]$Branch="master", [string[]]$Uncomment) {
$content = Invoke-WebRequest -uri "https://raw.github.com/$UserRepo/$Branch/$Name.gitignore" |
Select-Object -Exp Content |
%{ $origContent = $_; $UnComment |% { $origContent -replace "(?m)^#$_", "$_" } }
if ($PassThru) {
$content
} else {
$content | Out-File .gitignore
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment