[CmdletBinding()] # Fail on unknown args param ( [string]$src, # Ignore project structure problems [switch]$skipstructurecheck = $false, [switch]$overwriteprops = $false, [switch]$dryrun = $false, [switch]$help = $false ) function Print-Usage { Write-Output "Steve's UE4 Git Repo Setup Tool" Write-Output " Run this on your just-created UE4 project folder." Write-Output " .gitattributes and .gitignore will be overwritten" Write-Output "Usage:" Write-Output " ue4-git-setup.ps1 [[-src:]sourcefolder] [Options]" Write-Output " " Write-Output " -src : Source folder (current folder if omitted)" Write-Output " : (should be root of trunk in new repo)" Write-Output " -dryrun : Don't perform any actual actions, just report on what you would do" Write-Output " -help : Print this help" } $gitlfs_notlocked = @" *.fbx *.zip *.bmp *.afphoto *.exr *.dll *.mlt *.png *.jpg *.afdesign *.blend *.wav *.pdf *.tiff *.mp3 "@ $gitlfs_locked = @" *.uasset *.umap "@ $gitignore = @" # Visual Studio .vs/ # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app *.ipa # These project files can be generated by the engine *.xcodeproj *.xcworkspace *.sln *.suo *.opensdf *.sdf *.VC.db *.VC.opendb # Binary Files Binaries/* Plugins/*/Binaries/* # Builds Build/* # Whitelist PakBlacklist-.txt files !Build/*/ Build/*/** !Build/*/PakBlacklist*.txt # Don't ignore icon files in Build !Build/**/*.ico # Built data for maps *_BuiltData.uasset # Configuration files generated by the Editor Saved/* # Compiled source files for the engine to use Intermediate/* Plugins/*/Intermediate/* # Cache files for the editor to use DerivedDataCache/* # Localisation intermediate / export files Content/Localization/**/*.csv Content/Localization/**/*.po Content/Localization/**/*.archive # Temp files *.blend1 # Exported files in Content Content/**/*.bmp Content/**/*.png Content/**/*.jpg Content/**/*.tif Content/**/*.tiff Content/**/*.tga Content/**/*.fbx Content/**/*.exr Content/**/*.mp3 Content/**/*.wav "@ if ($help) { Print-Usage Exit 0 } if ($src.Length -eq 0) { $src = "." Write-Verbose "-src not specified, assuming current directory" } $ErrorActionPreference = "Stop" if ($src -ne ".") { Push-Location $src if ($LASTEXITCODE -ne 0) { Write-Output "ERROR: Unable to change directory to '$src', exiting" Exit 1 } } try { # Check if we're a git repo already if (-not (Test-Path ".git")) { Write-Output "Creating git repo" git init } # Add .gitignore FIRST before LFS # Otherwise lockable files that are ignored can be made read-only Write-Output "Creating .gitignore" Set-Content .gitignore $gitignore # init LFS Write-Output "Enabling Git LFS" git lfs install # track, including lockable types Write-Output "Tracking Git LFS Files" foreach($f in $gitlfs_notlocked -split "\r?\n") { git lfs track "$f" } foreach($f in $gitlfs_locked -split "\r?\n") { git lfs track --lockable "$f" } # TODO git submodule UE4Plugin } catch { Write-Output $_.Exception.Message Exit 9 } if ($src -ne ".") { Pop-Location }