Fix locale-dependent digits in padded version strings#399
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
device.appVersionPaddedanddevice.sdkVersionPaddedemitting non-ASCII digits on devices whose default locale uses a non-Latin numbering system (e.g.ar-EG,fa-IR,bn-BD).CHANGELOG.mdentry under2.7.13.Checklist
DeviceHelperAsPaddedTest.ktcoveringar-EG,fa-IR,bn-BD, and the beta-appendix / non-numeric-appendix branches.)CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.ktlintin the main directory and fixed any issues.Greptile Summary
This PR fixes locale-dependent digit rendering in
asPadded()by pinning all fourString.formatcalls toLocale.US, and widens the function visibility fromprivatetointernalto enable unit testing. Six new tests cover Arabic-Indic, Extended Arabic-Indic, and Bengali locales, plus the beta-appendix and non-numeric-appendix branches.Confidence Score: 5/5
Safe to merge — targeted, well-tested fix with no behavioral changes outside locale-digit normalization.
All four
String.formatcalls are correctly pinned toLocale.US,java.util.Localewas already imported, and six new unit tests cover every affected branch including edge-locale cases. No P0 or P1 findings.No files require special attention.
Important Files Changed
Locale.USto all fourString.formatcalls inasPadded()and widens visibility tointernalfor testing;java.util.Localewas already imported.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["asPadded() called on version string"] --> B["split on '-'"] B --> C{Has appendix?} C -- yes --> D["split appendix on '.'"] D --> E{Numeric suffix?} E -- yes --> F["String.format(Locale.US, '%03d', num)"] E -- no --> G["Keep label as-is"] C -- no --> H["Split version on '.'"] F --> H G --> H H --> I["String.format(Locale.US, '%03d', major)"] I --> J{minor present?} J -- yes --> K["String.format(Locale.US, '%03d', minor)"] J -- no --> M K --> L{patch present?} L -- yes --> N["String.format(Locale.US, '%03d', patch)"] L -- no --> M N --> M["Concatenate newVersion + appendix"] M --> O["Return ASCII-only padded string"]Reviews (1): Last reviewed commit: "Fix locale-dependent digits in padded ve..." | Re-trigger Greptile