Skip to content

Commit

Permalink
fix(update): only create a channel with branch name when branch is cr…
Browse files Browse the repository at this point in the history
…eated
  • Loading branch information
byCedric committed Nov 7, 2022
1 parent 9a415fe commit 56871ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/eas-cli/src/branch/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,22 @@ export async function ensureBranchExistsAsync(
appId: string;
branchName: string;
}
): Promise<{ branchId: string }> {
): Promise<{ branchId: string; branchIsCreated: boolean }> {
try {
const updateBranch = await BranchQuery.getBranchByNameAsync(graphqlClient, {
appId,
name: branchName,
});

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;
}
Expand Down
15 changes: 9 additions & 6 deletions packages/eas-cli/src/commands/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 56871ac

Please sign in to comment.