Skip to content

Commit ee5a886

Browse files
fix: git engine update (#55)
1 parent 54fa684 commit ee5a886

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"type": "string",
2121
"description": "git source repository"
2222
},
23+
"gitBranch": {
24+
"type": "string",
25+
"description": "git branch to checkout",
26+
"default": "main"
27+
},
2328
"gitDependenciesCachePath": {
2429
"type": "string",
2530
"description": "Path to git dependencies cache folder <RUNREAL_GIT_DEPENDENCIES_CACHE_PATH>"

src/commands/engine/update.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const update = new Command<GlobalOptions>()
1616
.option(
1717
'-b, --branch <checkout:string>',
1818
'git checkout (branch | tag | commit)',
19-
{ default: 'main' },
2019
)
2120
.option('-r, --remote <remote:string>', 'git remote', { default: 'origin' })
2221
.option('-c, --clean', 'if we should run a git clean before updating', {
@@ -41,35 +40,37 @@ export const update = new Command<GlobalOptions>()
4140
} = options as UpdateOptions
4241

4342
const cfg = Config.getInstance().mergeConfigCLIConfig({ cliOptions: options })
43+
const branchArg = branch || cfg.engine.gitBranch
44+
4445
const isRepo = await isGitRepo(cfg.engine.path)
4546
if (!isRepo) {
4647
throw new ValidationError(
4748
`Engine path ${cfg.engine.path} is not a git repository`,
4849
)
4950
}
5051
if (clean) {
51-
const clean = await exec('git', [
52+
const _clean = await exec('git', [
5253
'clean',
5354
gitCleanFlags ? gitCleanFlags : '-fxd',
5455
], { cwd: cfg.engine.path, dryRun })
5556
}
5657
// Prevent the default engine hooks from running
5758
await deleteEngineHooks(cfg.engine.path)
5859

59-
const fetch = await exec('git', [
60+
const _fetch = await exec('git', [
6061
'fetch',
6162
remote,
62-
branch,
63+
branchArg,
6364
], { cwd: cfg.engine.path, dryRun })
6465

65-
const checkout = await exec('git', [
66+
const _checkout = await exec('git', [
6667
'checkout',
6768
'--quiet',
6869
'--force',
69-
branch,
70+
branchArg,
7071
], { cwd: cfg.engine.path, dryRun })
7172

72-
const reset = await exec('git', [
73+
const _reset = await exec('git', [
7374
'reset',
7475
'--hard',
7576
'FETCH_HEAD',

src/lib/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const ConfigSchema = z.object({
3030
path: z.string().describe('Path to the engine folder'),
3131
repoType: z.string().describe('git or perforce'),
3232
gitSource: z.string().optional().describe('git source repository'),
33+
gitBranch: z.string().optional().describe('git branch to checkout').default('main'),
3334
gitDependenciesCachePath: z
3435
.string()
3536
.optional()

src/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export const runEngineSetup = async (
249249

250250
const deps = await exec(engine.getGitDependencesBin(), args, { cwd: enginePath, dryRun })
251251

252-
await exec(engine.getGenerateScript(), [])
252+
await exec(engine.getGenerateScript(), [], { dryRun })
253253
}
254254

255255
export const deleteEngineHooks = async (enginePath: string) => {

0 commit comments

Comments
 (0)