Repository navigation
Fix firmware version parser to accept SemVer 2.0 build metadata - #12
Merged
Merged
Conversation
- Update FIRMWARE_VERSION_REGEX to accept dot-separated build metadata identifiers following SemVer 2.0 spec: [0-9A-Za-z-] characters with dot separators - Fix all three regexes consistently (main parser, full device format, semver with build) - Now accepts versions like garagedoor@1.2.2+a57a610-dirty (dirty git builds) - Add comprehensive unit tests for: - Dirty git tags (a57a610-dirty) - Simple hash build metadata (a4eda92) - Dot-separated identifiers (abc.def-1, e2e-5f3075a) - Invalid formats (empty metadata, spaces, double plus signs) - Notify eligibility for dirty-tagged older devices - Version comparison ignores build metadata (as per SemVer 2.0) - All 244 tests passing Fixes issue where devices with dirty git builds were not recognized for OTA notifications. Co-authored-by: James Brown <JamesSmartCell@users.noreply.github.com>
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.
Problem
Devices built from dirty git trees report versions like
garagedoor@1.2.2+a57a610-dirty, which fail the current firmware version regex. This causes the device to not be recognized as projectgaragedoor, andPOST /api/firmware/:project/notify(and upload?notify=true) skips it, showing "Notified 0 device(s)" even though the device is connected.Solution
Updated the firmware version parser to accept SemVer 2.0 compliant build metadata:
[0-9A-Za-z-]a57a610-dirty,abc.def-1,e2e-5f3075aChanges
Updated three regexes consistently to accept proper SemVer 2.0 build metadata:
FIRMWARE_VERSION_REGEX(line 19)extractSemver()(line 69)extractSemver()(line 75)Regex pattern:
[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*Maintained existing behavior:
MAJOR.MINOR.PATCHTesting
Added comprehensive unit tests for:
garagedoor@1.2.2+a57a610-dirty(dirty git build)garagedoor@1.2.0+a4eda92(simple hash)garagedoor@1.2.0(no build metadata)abc.def-1,e2e-5f3075agaragedoor@1.2(incomplete semver)@1.2.0(no project)garagedoor@1.2.0+(empty metadata)garagedoor@1.2.0+a b(spaces)garagedoor@1.2.0+a+b(double plus)garagedoor@1.2.0+a..b(double dot)Test Results: ✅ All 244 tests passing (14 test files, 50 tests in firmware-version-parser)
Impact