Skip to content

Allow apphosting:backend:create to work with source deploy backends#10094

Draft
falahat wants to merge 15 commits intomainfrom
createSourceBackends
Draft

Allow apphosting:backend:create to work with source deploy backends#10094
falahat wants to merge 15 commits intomainfrom
createSourceBackends

Conversation

@falahat
Copy link
Copy Markdown
Contributor

@falahat falahat commented Mar 13, 2026

The current flow frustratingly forces you to set up Github connections.

Description

This just allows the interactive flow for backends:create to be able to skip Github connections. This is already possible with firebase init and the non-interactive mode of backend:create.

Scenarios Tested

Interactive flow:

  • Create a backend using the Github flow
  • Create a backend and say no to the Github flow

Sample Commands

firebase apphosting:backend:create

…s well. The current flow frustratingly forces you to set up Github connections.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the apphosting:backend:create command by providing users with the flexibility to choose their deployment method. Previously, creating a backend implicitly required linking a GitHub repository. With this change, users can now opt for local source deployment, streamlining the process for those who do not wish to integrate with GitHub, while still retaining the GitHub deployment option.

Highlights

  • Flexible Deployment Method Selection: Introduced a new prompt during backend creation that allows users to choose between 'GitHub' and 'Local Source' deployment methods, removing the previous mandatory GitHub connection requirement.
  • Source Deployment Support: Enabled the apphosting:backend:create command to successfully create backends for local source deployments, bypassing GitHub repository linking and branch prompting.
  • Conditional Rollout and Traffic Policy: Updated the logic to conditionally skip the rollout and default traffic policy setup if a GitHub branch is not provided, which is the case for local source deployments.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/apphosting/backend.spec.ts
    • Added new imports for doSetup, githubConnections, webApps, ensureApiEnabled, and rollout.
    • Declared new Sinon stubs for ensure, linkGitHubRepository, promptGitHubBranch, getOrCreateWebApp, and orchestrateRollout.
    • Introduced a new test suite for doSetup that includes test cases for both source deployment and GitHub deployment scenarios, verifying the new conditional logic.
  • src/apphosting/backend.ts
    • Implemented a select prompt to allow users to choose between 'GitHub' and 'Local Source' deployment methods.
    • Conditionalized the GitHub repository linking and branch prompting based on the selected deployment method.
    • Adjusted the prompt message for the app's root directory.
    • Modified the condition for skipping rollout and default traffic policy to include cases where no branch is provided (i.e., for source deployments), in addition to non-interactive mode.
    • Removed the FirebaseError that was previously thrown if a branch was not set, as it is now a valid scenario for source deployments.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable improvement by allowing apphosting:backend:create to support source-based deployments, removing the previous requirement to connect a GitHub repository. The changes are logical and well-implemented. The accompanying tests have been updated to cover both the new source deployment flow and the existing GitHub flow, ensuring good test coverage. I have one minor suggestion to remove a redundant log message to improve the command's output clarity for users.

@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 13, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request extends the apphosting:backend:create command to support creating backends for local source deployments, in addition to the existing GitHub-based deployments. This is a great improvement for user experience. The changes involve adding a prompt to select the deployment method and adjusting the logic accordingly. New tests have been added to cover these new code paths.

I have a couple of points of feedback regarding the user interaction flow and a potentially unused variable for source deployments. Please see my detailed comments.

@falahat falahat changed the title Allow apphosting:backend:create to work with source deploy backends a… Allow apphosting:backend:create to work with source deploy backends Mar 20, 2026
@falahat
Copy link
Copy Markdown
Contributor Author

falahat commented Mar 30, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a choice between 'GitHub' and 'Local Source' deployment methods in the doSetup function for App Hosting. It updates the setup flow to conditionally prompt for repository details only when the GitHub method is selected and adjusts the post-creation logic to skip traffic policy configuration for local source deployments. A suggestion was made to extract the GitHub-specific setup logic into a helper function to reduce nesting and improve readability, adhering to the repository's style guide.

Comment on lines +122 to +136
if (deployMethod === "github") {
if (!rootDir) {
rootDir = await input({
default: "/",
message: "Specify your app's root directory relative to your repository",
});
}

gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location);
// TODO: Once tag patterns are implemented, prompt which method the user
// prefers. We could reduce the number of questions asked by letting people
// enter tag:<pattern>?
branch = await githubConnections.promptGitHubBranch(gitRepositoryLink);
logSuccess(`Repo linked successfully!\n`);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and reduce nesting in the doSetup function, consider extracting the GitHub setup logic into a new helper function. This aligns with the style guide's recommendation to "Reduce nesting as much as possible" (line 33).

You could define a new helper function like this:

async function setupGithubDeployment(
  projectId: string,
  location: string,
  currentRootDir: string | undefined,
): Promise<{
  rootDir: string;
  gitRepositoryLink: GitRepositoryLink;
  branch: string;
}> {
  let rootDir = currentRootDir;
  if (!rootDir) {
    rootDir = await input({
      default: "/",
      message: "Specify your app's root directory relative to your repository",
    });
  }

  const gitRepositoryLink = await githubConnections.linkGitHubRepository(projectId, location);
  const branch = await githubConnections.promptGitHubBranch(gitRepositoryLink);
  logSuccess(`Repo linked successfully!\n`);
  return { rootDir: rootDir!, gitRepositoryLink, branch };
}

And then call it from doSetup.

    if (deployMethod === "github") {
      const githubSettings = await setupGithubDeployment(projectId, location, rootDir);
      rootDir = githubSettings.rootDir;
      gitRepositoryLink = githubSettings.gitRepositoryLink;
      branch = githubSettings.branch;
    }
References
  1. The style guide recommends reducing code nesting as much as possible to improve readability and maintainability. Extracting this block of logic into a helper function would follow this best practice. (link)

@falahat falahat requested review from Yuangwang and annajowang March 30, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants