From 56871ac9ee9d917180e7bb36f7a5a9304ea705bd Mon Sep 17 00:00:00 2001 From: Cedric van Putten Date: Mon, 7 Nov 2022 14:37:57 +0100 Subject: [PATCH] fix(update): only create a channel with branch name when branch is created --- packages/eas-cli/src/branch/queries.ts | 6 +++--- packages/eas-cli/src/commands/update/index.ts | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/eas-cli/src/branch/queries.ts b/packages/eas-cli/src/branch/queries.ts index 15663287ae..ca292e01b4 100644 --- a/packages/eas-cli/src/branch/queries.ts +++ b/packages/eas-cli/src/branch/queries.ts @@ -160,7 +160,7 @@ export async function ensureBranchExistsAsync( appId: string; branchName: string; } -): Promise<{ branchId: string }> { +): Promise<{ branchId: string; branchIsCreated: boolean }> { try { const updateBranch = await BranchQuery.getBranchByNameAsync(graphqlClient, { appId, @@ -168,14 +168,14 @@ export async function ensureBranchExistsAsync( }); const { id } = updateBranch; - return { branchId: id }; + return { branchId: id, branchIsCreated: false }; } catch (error) { if (error instanceof BranchNotFoundError) { const newUpdateBranch = await createUpdateBranchOnAppAsync(graphqlClient, { appId, name: branchName, }); - return { branchId: newUpdateBranch.id }; + return { branchId: newUpdateBranch.id, branchIsCreated: true }; } else { throw error; } diff --git a/packages/eas-cli/src/commands/update/index.ts b/packages/eas-cli/src/commands/update/index.ts index fdeb81faf5..f1f7f2ad36 100644 --- a/packages/eas-cli/src/commands/update/index.ts +++ b/packages/eas-cli/src/commands/update/index.ts @@ -376,15 +376,18 @@ export default class UpdatePublish extends EasCommand { .map(pair => pair[0]); } - const { branchId } = await ensureBranchExistsAsync(graphqlClient, { + const { branchId, branchIsCreated } = await ensureBranchExistsAsync(graphqlClient, { appId: projectId, branchName, }); - await ensureChannelExistsAsync(graphqlClient, { - appId: projectId, - branchId, - channelName: branchName, - }); + if (branchIsCreated) { + await ensureChannelExistsAsync(graphqlClient, { + appId: projectId, + branchId, + channelName: branchName, + }); + } + Log.withTick(`Channel: ${chalk.bold(branchName)} pointed at branch: ${chalk.bold(branchName)}`); const gitCommitHash = await getVcsClient().getCommitHashAsync();