Update check-go-version-yaml.sh
update code
Summary of Changes
Hello @AfuroIsCrazy, I'm Gemini Code Assist[^1]! 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 refactors and enhances the check-go-version-yaml.sh script. The changes aim to improve the script's reliability and flexibility in identifying and validating Go versions specified within YAML configuration files. By consolidating logic, using more robust parsing techniques, and refining error handling, the script now provides a more comprehensive and user-friendly mechanism for ensuring consistent Go version declarations across a project's YAML assets.
Highlights
-
Refactored Version Checking Logic: The two previous functions,
check_go_version_yamlandcheck_go_version_env_variable, have been consolidated into a single, more versatile helper function namedcheck_yaml_version_pattern. This new function is designed to handle various YAML key patterns for Go version extraction. -
Improved YAML Parsing with AWK: The script now utilizes
awkfor extracting Go versions from YAML files, replacing the less robustgrepandsedcombination. This change significantly improves the script's ability to correctly parse versions regardless of quoting styles or surrounding whitespace. -
Enhanced Error Handling and Reporting: A global
EXIT_STATUSvariable has been introduced to track the overall success or failure of the checks. Instead of exiting on the first error, the script now processes all relevant YAML files and reports all discrepancies before exiting with an appropriate status. The output also includes clearer success and failure messages with emojis. -
Safer File Iteration: The method for iterating through YAML files has been updated to use
find ... -print0 | while IFS= read -r -d $'\0' file; do. This approach robustly handles filenames that may contain spaces or special characters, preventing potential issues.
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 :thumbsup: and :thumbsdown: 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.
[^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.
@afuroiscrazy, remember to re-request review from reviewers when ready