Repository navigation
ci: optimize trailing whitespace check - #1617
hariharimc1962-ui wants to merge 1 commit into
Conversation
Replace the per-file subprocess loop with a single git grep across tracked YANG models. This avoids spawning 233+ egrep processes on every pull request. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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 optimizes the continuous integration process by streamlining the trailing whitespace validation for YANG models. By replacing a per-file loop with a single repository-level grep scan, the change reduces overhead and improves the overall efficiency of the CI pipeline. Highlights
Using Gemini Code AssistThe 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
Customization To customize the 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 Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request optimizes the trailing whitespace check in scripts/find_trailing_whitespace.sh by replacing a file-by-file loop with a single git grep command. The review feedback suggests a more idiomatic and readable way to handle the exit status of git grep under set -e instead of using an empty then block with a dummy command.
| tw_lines="" | ||
| if tw_lines=$(git grep -n -I -E '[[:blank:]]+$' -- 'release/models/*.yang'); then | ||
| : | ||
| else | ||
| grep_status=$? | ||
| if [ "$grep_status" -ne 1 ]; then | ||
| exit "$grep_status" | ||
| fi | ||
| done | ||
| fi |
There was a problem hiding this comment.
Using an if statement with a dummy : command to capture the exit status of a command substitution under set -e is non-idiomatic and less readable.
By using the || operator, we can safely capture the exit status of git grep without triggering set -e and without needing an empty then block. This makes the script cleaner and more maintainable.
| tw_lines="" | |
| if tw_lines=$(git grep -n -I -E '[[:blank:]]+$' -- 'release/models/*.yang'); then | |
| : | |
| else | |
| grep_status=$? | |
| if [ "$grep_status" -ne 1 ]; then | |
| exit "$grep_status" | |
| fi | |
| done | |
| fi | |
| grep_status=0 | |
| tw_lines=$(git grep -n -I -E '[[:blank:]]+$' -- 'release/models/*.yang') || grep_status=$? | |
| if [ "$grep_status" -ne 0 ] && [ "$grep_status" -ne 1 ]; then | |
| exit "$grep_status" | |
| fi |
Summary
git grepscan across tracked YANG models.egrepsubprocesses and shell variable accumulation per pull request.10 performance improvements identified
git grepscan for whitespace checks.openconfig-cibinary in the breaking-change workflow.git checkoutoperations in diff validation with worktrees or direct file extraction.cloudbuild.yaml.Validation
git diff --checkgit grep -n -I -E '[[:blank:]]+$' -- 'release/models/*.yang'(no matches in the current tree)