Skip to content

core: rework apple silicon device detection#1526

Merged
abiosoft merged 3 commits intomainfrom
prevent-macos-check-linux
Feb 28, 2026
Merged

core: rework apple silicon device detection#1526
abiosoft merged 3 commits intomainfrom
prevent-macos-check-linux

Conversation

@abiosoft
Copy link
Copy Markdown
Owner

No description provided.

Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Apple Silicon chip detection logic in util/macos.go to prevent system_profiler from being called on non-macOS platforms (e.g., Linux). It replaces the old IsMx(x int) function with a new IsMxOrNewer(min int) function that checks if the chip generation is at least min, and introduces a chipTypeDetector interface (with a systemProfilerChipDetector production implementation) to enable testing without invoking real system commands.

Changes:

  • IsMx is replaced by IsMxOrNewer(min int), which returns true when the chip is an Apple Silicon M{n} with n >= min.
  • A chipTypeDetector interface and systemProfilerChipDetector struct are introduced; GetChipType() now guards with MacOS() before calling system_profiler, preventing the call on Linux.
  • New tests in util/macos_test.go cover parseMNumber and IsMxOrNewer using a fakeDetector to stub the chip type.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
util/macos.go Replaces IsMx with IsMxOrNewer, adds chipTypeDetector interface, guards system_profiler call with MacOS(), extracts parseMNumber helper
util/macos_test.go New test file with table-driven tests for parseMNumber and IsMxOrNewer using a fake detector

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
@abiosoft abiosoft changed the title core: prevent calling system_profiler on Linux core: rework apple silicon device detection Feb 28, 2026
@abiosoft abiosoft merged commit b8890a9 into main Feb 28, 2026
15 checks passed
@abiosoft abiosoft deleted the prevent-macos-check-linux branch February 28, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants