diff --git a/cli/src/commands/gitsync-settings/push.ts b/cli/src/commands/gitsync-settings/push.ts index f2b5bf3d72..2e7f050207 100644 --- a/cli/src/commands/gitsync-settings/push.ts +++ b/cli/src/commands/gitsync-settings/push.ts @@ -30,7 +30,7 @@ export async function pushGitSyncSettings( ) { // Validate branch configuration like sync commands try { - await validateBranchConfiguration(); + await validateBranchConfiguration({ yes: opts.yes }); } catch (error) { if (error instanceof Error && error.message.includes("overrides")) { log.error(error.message); diff --git a/cli/src/commands/sync/sync.ts b/cli/src/commands/sync/sync.ts index bb641b5e0d..b3e5f9825f 100644 --- a/cli/src/commands/sync/sync.ts +++ b/cli/src/commands/sync/sync.ts @@ -1265,7 +1265,7 @@ export async function pull( // Validate branch configuration early try { - await validateBranchConfiguration(false, opts.yes); + await validateBranchConfiguration(opts); } catch (error) { if (error instanceof Error && error.message.includes("overrides")) { log.error(error.message); @@ -1690,7 +1690,7 @@ export async function push( // Validate branch configuration early try { - await validateBranchConfiguration(false, opts.yes); + await validateBranchConfiguration(opts); } catch (error) { if (error instanceof Error && error.message.includes("overrides")) { log.error(error.message); @@ -2358,6 +2358,7 @@ const command = new Command() .option("--include-groups", "Include syncing groups") .option("--include-settings", "Include syncing workspace settings") .option("--include-key", "Include workspace encryption key") + .option("--skip-branch-validation", "Skip git branch validation and prompts") .option("--json-output", "Output results in JSON format") .option( "-i --includes ", @@ -2405,6 +2406,7 @@ const command = new Command() .option("--include-groups", "Include syncing groups") .option("--include-settings", "Include syncing workspace settings") .option("--include-key", "Include workspace encryption key") + .option("--skip-branch-validation", "Skip git branch validation and prompts") .option("--json-output", "Output results in JSON format") .option( "-i --includes ", diff --git a/cli/src/core/conf.ts b/cli/src/core/conf.ts index 273891b42b..5a56f97435 100644 --- a/cli/src/core/conf.ts +++ b/cli/src/core/conf.ts @@ -36,6 +36,7 @@ export interface SyncOptions { includeGroups?: boolean; includeSettings?: boolean; includeKey?: boolean; + skipBranchValidation?: boolean; message?: string; includes?: string[]; extraIncludes?: string[]; @@ -355,10 +356,9 @@ export async function mergeConfigWithConfigFile( // Validate branch configuration early in the process export async function validateBranchConfiguration( - skipValidation?: boolean, - autoAccept?: boolean + opts: Pick ): Promise { - if (skipValidation || !isGitRepository()) { + if (opts.skipBranchValidation || !isGitRepository()) { return; } @@ -400,7 +400,7 @@ export async function validateBranchConfiguration( ); const shouldCreate = - autoAccept || + opts.yes || (await Confirm.prompt({ message: `Create empty branch configuration for '${currentBranch}'?`, default: true,