Skip to content

Fix matching operator for ignored files in size-labeler.sh#1034

Open
mhucka wants to merge 6 commits intoquantumlib:mainfrom
mhucka:fix-size-labeler
Open

Fix matching operator for ignored files in size-labeler.sh#1034
mhucka wants to merge 6 commits intoquantumlib:mainfrom
mhucka:fix-size-labeler

Conversation

@mhucka
Copy link
Copy Markdown
Collaborator

@mhucka mhucka commented Apr 3, 2026

The IGNORED array in size-labeler.sh contains glob patterns (e.g., *_pb2.py, .*.lock). Using the Bash regex match operator =~ would fail to match these patterns.

The following demonstrates the problem:

# bash -c 'p="*_pb2.py"; [[ a_pb2.py =~ $p ]]'
bash: line 1: [[: invalid regular expression `*_pb2.py': 
Invalid preceding regular expression

This is the same fix applied in the Cirq repo in PR #7986 there.

In addition, this PR adds support for getting more than 100 files back from GitHub, a problem that was flagged by Gemini Code Assist. The solution was implemented with the help of Gemini CLI.

The `IGNORED` list contain path globs, but they were getting tested
using bash regex syntax, and this would not produce the right results.
@github-actions github-actions bot added the Size: XS <10 lines changed label Apr 3, 2026
@mhucka mhucka marked this pull request as ready for review April 3, 2026 01:42
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 updates the size-labeler.sh script to use Bash glob patterns for file exclusion and increases the GitHub API per_page parameter to 100. While the increase in page size is helpful, feedback was provided noting that the script still fails to handle pagination for pull requests exceeding 100 files, which could result in inaccurate size labels.

This enhances the code to support getting more than 100 files from
GitHub.

(Written with the help of Gemini CLI.)
@github-actions github-actions bot added size: M 50< lines changed <250 and removed Size: XS <10 lines changed labels Apr 3, 2026
@mhucka
Copy link
Copy Markdown
Collaborator Author

mhucka commented Apr 3, 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 updates the compute_changes function in dev_tools/ci/size-labeler.sh to implement pagination when querying the GitHub API for pull request files, ensuring accurate size labeling for large changesets. It also improves shell script robustness through better variable quoting and refined pattern matching. Feedback was provided to optimize performance by reducing the number of jq process executions within the file processing loop, suggesting a single-pass approach to extract filenames and change counts.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions github-actions bot added size: S 10< lines changed <50 and removed size: M 50< lines changed <250 labels Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant