Skip to content

Commit 60542c1

Browse files
authored
feat: detect old onkernel/tap and show migration instructions (#90)
## Summary - Detects when users have `kernel` installed from the old `onkernel/tap` instead of `kernel/tap` - Shows migration instructions instead of the standard upgrade command when on the old tap This helps users who installed via `onkernel/tap/kernel` migrate to `kernel/tap/kernel` which is where new releases are published. ## Example output When a user on `onkernel/tap` sees an update available: ``` INFO A new release of kernel is available: 0.13.5 → 0.14.0 INFO Release notes: https://github.com/kernel/cli/releases/tag/v0.14.0 WARNING You have kernel installed from the old tap (onkernel/tap). WARNING To upgrade, switch to the new tap: brew uninstall kernel brew install kernel/tap/kernel ``` ## Test plan - [ ] Verify detection works on a machine with `onkernel/tap/kernel` installed - [ ] Verify normal upgrade message shows for `kernel/tap/kernel` users - [ ] Verify non-Homebrew installs still show normal upgrade message <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds logic to identify Homebrew installs from the deprecated `onkernel/tap` by scanning `INSTALL_RECEIPT.json` in common Cellar paths. > > - New `isOnOldBrewTap()` checks for `"tap":"onkernel/tap"` in Homebrew receipts > - `printUpgradeMessage` now warns and shows `brew uninstall kernel` + `brew install kernel/tap/kernel` when on old tap; otherwise retains existing upgrade suggestion behavior > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 54cbea0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent ca377b6 commit 60542c1

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

pkg/update/check.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,39 @@ func FetchLatest(ctx context.Context) (tag string, url string, err error) {
125125
return "", "", errors.New("no stable releases found")
126126
}
127127

128+
// isOnOldBrewTap checks if the user has kernel installed from onkernel/tap
129+
// instead of the current kernel/tap by checking the install receipt.
130+
func isOnOldBrewTap() bool {
131+
// Find the Homebrew Cellar path
132+
cellarPaths := []string{
133+
"/opt/homebrew/Cellar/kernel", // Apple Silicon
134+
"/usr/local/Cellar/kernel", // Intel Mac
135+
"/home/linuxbrew/.linuxbrew/Cellar/kernel", // Linux
136+
}
137+
138+
for _, cellar := range cellarPaths {
139+
entries, err := os.ReadDir(cellar)
140+
if err != nil {
141+
continue
142+
}
143+
for _, entry := range entries {
144+
if !entry.IsDir() {
145+
continue
146+
}
147+
receiptPath := filepath.Join(cellar, entry.Name(), "INSTALL_RECEIPT.json")
148+
data, err := os.ReadFile(receiptPath)
149+
if err != nil {
150+
continue
151+
}
152+
// Check if installed from onkernel/tap
153+
if strings.Contains(string(data), `"tap":"onkernel/tap"`) {
154+
return true
155+
}
156+
}
157+
}
158+
return false
159+
}
160+
128161
// printUpgradeMessage prints a concise upgrade banner.
129162
func printUpgradeMessage(current, latest, url string) {
130163
cur := strings.TrimPrefix(current, "v")
@@ -134,6 +167,18 @@ func printUpgradeMessage(current, latest, url string) {
134167
if url != "" {
135168
pterm.Info.Printf("Release notes: %s\n", url)
136169
}
170+
171+
method, _ := DetectInstallMethod()
172+
if method == InstallMethodBrew && isOnOldBrewTap() {
173+
pterm.Println()
174+
pterm.Warning.Println("You have kernel installed from the old tap (onkernel/tap).")
175+
pterm.Warning.Println("To upgrade, switch to the new tap:")
176+
pterm.Println()
177+
pterm.Println(" brew uninstall kernel")
178+
pterm.Println(" brew install kernel/tap/kernel")
179+
return
180+
}
181+
137182
if cmd := SuggestUpgradeCommand(); cmd != "" {
138183
pterm.Info.Printf("To upgrade, run: %s\n", cmd)
139184
} else {

0 commit comments

Comments
 (0)