-
Notifications
You must be signed in to change notification settings - Fork 628
dataconnect: emulator.sh: add flag to use the same data connect emulator as the gradle build #7209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… command-line argument, causing it to use the same data connect emulator binary that is used by the gradle build.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @dconeybe, 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 significantly enhances the emulator.sh
script by integrating it more deeply with the project's Gradle build system. The primary goal is to allow developers to easily use the exact Data Connect emulator binary that Gradle manages, thereby streamlining the development workflow and ensuring environment consistency. Additionally, the PR refactors error handling for better maintainability.
Highlights
- Enhanced Emulator Binary Selection: The
emulator.sh
script now supports a special value of "gradle" for the-c
command-line argument. When this value is provided, the script will automatically execute the necessary Gradle task to download the Data Connect emulator binary and then use that specific binary, ensuring consistency with the Gradle build's environment. - Improved Error Handling: A new utility function,
log_error_and_exit
, has been introduced withinemulator.sh
to standardize error logging and script termination, replacing directecho
andexit
calls for error conditions. - Updated Documentation: The command-line help message for the
-c
option inemulator.sh
has been updated to clearly document the new "gradle" functionality, guiding users on how to leverage this feature.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
There was a problem hiding this 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 useful feature to the emulator.sh
script, allowing it to use the emulator binary managed by Gradle. The implementation is straightforward and the addition of a centralized error-handling function is a good improvement.
My review focuses on improving the script's robustness, particularly in handling filenames that may contain spaces. I've pointed out a couple of areas where unquoted variables could lead to bugs. The feedback is based on general shell scripting best practices, as exemplified by the Google Shell Style Guide. With these minor corrections, the script will be more reliable.
Coverage Report 1Affected ProductsNo changes between base commit (0c1302f) and merge commit (cafe14b).Test Logs |
Size Report 1Affected ProductsNo changes between base commit (0c1302f) and merge commit (cafe14b).Test Logs |
diff --git a/firebase-dataconnect/emulator/emulator.sh b/firebase-dataconnect/emulator/emulator.sh index 7358a82..3efc204 100755 --- a/firebase-dataconnect/emulator/emulator.sh +++ b/firebase-dataconnect/emulator/emulator.sh @@ -37,9 +37,10 @@ function parse_args { local OPTIND=1 local OPTERR=0 - while getopts ":c:p:v:hw" arg ; do + while getopts ":c:p:v:hwg" arg ; do case "$arg" in c) emulator_binary="${OPTARG}" ;; + g) emulator_binary="gradle" ;; p) postgresql_string="${OPTARG}" ;; v) preview_flags="${OPTARG}" ;; w) wipe_and_restart_postgres_pod=1 ;; @@ -107,6 +108,9 @@ function print_help { echo " will use the same CLI as the Gradle build. If not specified, or if specified " echo " as the empty string, then the emulator binary is downloaded." echo + echo " -g" + echo " Shorthand for: -c gradle" + echo echo " -p <postgresql_connection_string>" echo " Uses the given string to connect to the PostgreSQL server. If not specified " echo " the the default value of \"${DEFAULT_POSTGRESQL_STRING}\" is used."
Co-authored-by: Maneesh Tewani <maneesht@users.noreply.github.com>
This PR enhances the Data Connect
emulator.sh
script by adding support for the special valuegradle
to the-c
flag, causing it to use the same data connect emulator binary as the Gradle build. The new-g
flag was added as a convenient shorthand.Highlights
emulator.sh
script now supports a special value of "gradle" for the-c
command-line argument, or-g
as a shorthand. When this value is provided, the script will automatically execute the necessary Gradle task to download the Data Connect emulator binary and then use that specific binary, ensuring consistency with the Gradle build's environment.log_error_and_exit
, has been introduced withinemulator.sh
to standardize error logging and script termination, replacing directecho
andexit
calls for error conditions.-c
option inemulator.sh
has been updated to clearly document the new "gradle" functionality, guiding users on how to leverage this feature.