From 04cf6d8643908c4d1620d1bccae31dcce8726bad Mon Sep 17 00:00:00 2001 From: warman Date: Fri, 11 Apr 2025 12:39:23 -0400 Subject: [PATCH 1/3] fix: engine checkout branch --- schema.json | 4 ++++ src/commands/engine/update.ts | 14 ++++++++------ src/lib/schema.ts | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/schema.json b/schema.json index a9e582f..d335d3a 100644 --- a/schema.json +++ b/schema.json @@ -20,6 +20,10 @@ "type": "string", "description": "git source repository" }, + "gitBranch": { + "type": "string", + "description": "git branch to checkout" + }, "gitDependenciesCachePath": { "type": "string", "description": "Path to git dependencies cache folder " diff --git a/src/commands/engine/update.ts b/src/commands/engine/update.ts index c3d5c53..0c1413f 100644 --- a/src/commands/engine/update.ts +++ b/src/commands/engine/update.ts @@ -41,6 +41,8 @@ export const update = new Command() } = options as UpdateOptions const cfg = Config.getInstance().mergeConfigCLIConfig({ cliOptions: options }) + const branchArg = cfg.engine.gitBranch || branch + const isRepo = await isGitRepo(cfg.engine.path) if (!isRepo) { throw new ValidationError( @@ -48,7 +50,7 @@ export const update = new Command() ) } if (clean) { - const clean = await exec('git', [ + const _clean = await exec('git', [ 'clean', gitCleanFlags ? gitCleanFlags : '-fxd', ], { cwd: cfg.engine.path, dryRun }) @@ -56,20 +58,20 @@ export const update = new Command() // Prevent the default engine hooks from running await deleteEngineHooks(cfg.engine.path) - const fetch = await exec('git', [ + const _fetch = await exec('git', [ 'fetch', remote, - branch, + branchArg, ], { cwd: cfg.engine.path, dryRun }) - const checkout = await exec('git', [ + const _checkout = await exec('git', [ 'checkout', '--quiet', '--force', - branch, + branchArg, ], { cwd: cfg.engine.path, dryRun }) - const reset = await exec('git', [ + const _reset = await exec('git', [ 'reset', '--hard', 'FETCH_HEAD', diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 366dea1..fb666f2 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -30,6 +30,7 @@ export const ConfigSchema = z.object({ path: z.string().describe('Path to the engine folder'), repoType: z.string().describe('git or perforce'), gitSource: z.string().optional().describe('git source repository'), + gitBranch: z.string().optional().describe('git branch to checkout'), gitDependenciesCachePath: z .string() .optional() From eb76c48d4599c4e204dbb6a6b057154d7999cfc3 Mon Sep 17 00:00:00 2001 From: warman Date: Fri, 11 Apr 2025 12:48:17 -0400 Subject: [PATCH 2/3] fix: dry-run runEngineSetup --- src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 3951453..da5a065 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -249,7 +249,7 @@ export const runEngineSetup = async ( const deps = await exec(engine.getGitDependencesBin(), args, { cwd: enginePath, dryRun }) - await exec(engine.getGenerateScript(), []) + await exec(engine.getGenerateScript(), [], { dryRun }) } export const deleteEngineHooks = async (enginePath: string) => { From a2a806bd8405d375adbaa2066998fd8fbf6b905f Mon Sep 17 00:00:00 2001 From: warman Date: Fri, 11 Apr 2025 13:30:58 -0400 Subject: [PATCH 3/3] fix: default values --- schema.json | 3 ++- src/commands/engine/update.ts | 3 +-- src/lib/schema.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/schema.json b/schema.json index d335d3a..361156e 100644 --- a/schema.json +++ b/schema.json @@ -22,7 +22,8 @@ }, "gitBranch": { "type": "string", - "description": "git branch to checkout" + "description": "git branch to checkout", + "default": "main" }, "gitDependenciesCachePath": { "type": "string", diff --git a/src/commands/engine/update.ts b/src/commands/engine/update.ts index 0c1413f..a6a9e97 100644 --- a/src/commands/engine/update.ts +++ b/src/commands/engine/update.ts @@ -16,7 +16,6 @@ export const update = new Command() .option( '-b, --branch ', 'git checkout (branch | tag | commit)', - { default: 'main' }, ) .option('-r, --remote ', 'git remote', { default: 'origin' }) .option('-c, --clean', 'if we should run a git clean before updating', { @@ -41,7 +40,7 @@ export const update = new Command() } = options as UpdateOptions const cfg = Config.getInstance().mergeConfigCLIConfig({ cliOptions: options }) - const branchArg = cfg.engine.gitBranch || branch + const branchArg = branch || cfg.engine.gitBranch const isRepo = await isGitRepo(cfg.engine.path) if (!isRepo) { diff --git a/src/lib/schema.ts b/src/lib/schema.ts index fb666f2..25389af 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -30,7 +30,7 @@ export const ConfigSchema = z.object({ path: z.string().describe('Path to the engine folder'), repoType: z.string().describe('git or perforce'), gitSource: z.string().optional().describe('git source repository'), - gitBranch: z.string().optional().describe('git branch to checkout'), + gitBranch: z.string().optional().describe('git branch to checkout').default('main'), gitDependenciesCachePath: z .string() .optional()