-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathue-git-setup.ps1
223 lines (182 loc) · 4.55 KB
/
ue-git-setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
[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 Unreal Git Repo Setup Tool"
Write-Output " Run this on your just-created Unreal project folder."
Write-Output " .gitattributes and .gitignore will be overwritten"
Write-Output "Usage:"
Write-Output " ue-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"
}
$gitPluginURL = "[email protected]:sinbad/UE4GitPlugin.git"
$gitPluginBranch = "ue4_24-fixes"
$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-<BuildConfiguration>.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 (-not (Get-Module -ListAvailable -Name PsIni)) {
Write-Output "Missing module: PsIni"
Write-Output "This script uses PsIni to update DefaultEngine.ini"
Write-Output "Install it using 'Install-Module PsIni [-Scope CurrentUser]'"
Exit 2
}
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"
}
# Configure DefaultEngine.ini to make Git LFS operations MUCH faster
# [SystemSettingsEditor]
# r.Editor.SkipSourceControlCheckForEditablePackages = 1
# Seriously, without this saving a locked LFS file takes ~5s vs 0.5s
Import-Module PsIni
$engineIni = Get-IniContent "Config/DefaultEngine.ini"
$engineIni["SystemSettingsEditor"] = @{"r.Editor.SkipSourceControlCheckForEditablePackages" = "1"}
Out-IniFile -Force -InputObject $engineIni -FilePath "Config/DefaultEngine.ini"
# git submodule UE4Plugin
if (!(Test-Path "Plugins/UE4GitPlugin/GitSourceControl.uplugin")) {
Write-Output "Checking out $gitPluginURL/$gitPluginBranch..."
if (!(Test-Path Plugins)) {
New-Item -ItemType Directory Plugins > $null
}
git submodule add -b $gitPluginBranch $gitPluginURL Plugins/UE4GitPlugin
}
} catch {
Write-Output $_.Exception.Message
Exit 9
}
if ($src -ne ".") { Pop-Location }