[LTR] Infer kernel version from UPSTREAM_REF#49
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the lt_rebase.sh script to dynamically infer the kernel version from the UPSTREAM_REF parameter instead of hardcoding version "6.12". This enables the script to work seamlessly with different kernel versions (e.g., stable_6.18.y) by extracting the version number and constructing all branch references dynamically.
Key changes:
- Added kernel version extraction logic using regex pattern matching on
UPSTREAM_REF - Replaced all hardcoded "6.12" references with the dynamically extracted
KERNEL_VERSIONvariable - Added validation and error handling for version extraction with clear error messages
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
efbddb9 to
fb5f4c4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Validate UPSTREAM_REF format to prevent shell injection | ||
| case "$UPSTREAM_REF" in | ||
| stable_[0-9]*.[0-9]*.y) |
There was a problem hiding this comment.
The validation pattern stable_[0-9]*.[0-9]*.y uses glob patterns which are more permissive than intended. This would accept invalid formats like stable_123.y (missing second version number) or stable_.1.y (missing first version number). Consider using a more restrictive pattern like stable_[0-9]*[0-9].[0-9]*[0-9].y or handle validation in the extraction step.
There was a problem hiding this comment.
I can't see a condition where the upstream forgets to label this correctly.
There was a problem hiding this comment.
UPSTREAM_REF is optionally assigned by command line argument here, so this is just some validation that it is a reasonable value.
There was a problem hiding this comment.
I would replace '*" with '+' to be the same as the regex below.
There was a problem hiding this comment.
yea, good call. I made the regexs the same. Thanks!
Use the inferred kernel version to construct all of the other branch references in the script. This should allow an UPSTREAM_REF of stable_6.18.y to be passed and the script to work the same way it does today for 6.12
fb5f4c4 to
e711b0d
Compare
Use the inferred kernel version to construct all of the other branch references in the script. This should allow an UPSTREAM_REF of stable_6.18.y to be passed and the script to work the same way it does today for 6.12