Skip to content

Bug: Fix version pattern regex and clarify file size units #23

Description

@leogdion

Problem

  1. Version regex allows invalid formats:
    • DataSourcePipeline.swift:504: Pattern allows 4-part versions
    • macOS versions are max 3 parts (e.g., "14.2.1" not "14.2.1.1")
    • May cause incorrect reference resolution

Current:

let versionPattern = #/(\d+\.\d+(?:\.\d+)?(?:\.\d+)?)/#

Should be:

let versionPattern = #/(\d+\.\d+(?:\.\d+)?)/#
  1. File size unit ambiguity:
    • RestoreImageRecord.swift:128 and XcodeVersionRecord.swift:132
    • Uses 1,000,000,000 (SI decimal GB)
    • Not explicitly documented as Apple convention

Proposed Solution

  1. Fix regex: Remove optional 4th version component
  2. Document units: Add comment clarifying GB = 1,000,000,000 bytes (SI decimal, Apple convention)
// Apple uses decimal GB (1,000,000,000 bytes), not binary GiB (1,073,741,824)
let gb = Double(bytes) / 1_000_000_000

Impact

  • Correctness: Prevents incorrect version matching
  • Clarity: Explicit unit documentation
  • Consistency: Matches Apple's conventions

Files Affected

  • Examples/Bushel/Sources/BushelImages/DataSources/DataSourcePipeline.swift:504
  • Examples/Bushel/Sources/BushelImages/Models/RestoreImageRecord.swift:128
  • Examples/Bushel/Sources/BushelImages/Models/XcodeVersionRecord.swift:132

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions