update: magpie update in a Homebrew install (brew install magpie, from the new tap in magpie-releases) says to brew upgrade magpie instead of replacing the binary in brew's Cellar, which would leave brew thinking the old version is there
This commit is contained in:
3 files changed
+23
No files matched your search
@@ -176,6 +176,13 @@ func Bundle() string {
|
||||
return app
|
||||
}
|
||||
|
||||
// Homebrew is whether exe was installed by Homebrew (brew install magpie),
|
||||
// which keeps it in its Cellar and has to be the one to upgrade it: a
|
||||
// binary replaced under it leaves brew thinking the old version is there.
|
||||
func Homebrew(exe string) bool {
|
||||
return strings.Contains(filepath.ToSlash(exe), "/Cellar/magpie/")
|
||||
}
|
||||
|
||||
// Executable is the running binary, symlinks resolved.
|
||||
func Executable() (string, error) {
|
||||
exe, err := os.Executable()
|
||||
|
||||
@@ -30,3 +30,16 @@ func TestReleased(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomebrew(t *testing.T) {
|
||||
for exe, want := range map[string]bool{
|
||||
"/opt/homebrew/Cellar/magpie/0.1.126/bin/magpie": true,
|
||||
"/home/linuxbrew/.linuxbrew/Cellar/magpie/0.1.126/bin/magpie": true,
|
||||
"/usr/local/bin/magpie": false,
|
||||
"/Applications/magpie.app/Contents/MacOS/magpie": false,
|
||||
} {
|
||||
if Homebrew(exe) != want {
|
||||
t.Errorf("%s: %v", exe, !want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,9 @@ func updateCmd(args []string) error {
|
||||
fmt.Println(green.Render("✓"), "updated", tilde(app), "to", rel.Version, muted.Render("· quit and reopen magpie to use it"))
|
||||
return nil
|
||||
}
|
||||
if exe, err := update.Executable(); err == nil && update.Homebrew(exe) {
|
||||
return fmt.Errorf("this magpie was installed with Homebrew; update it with: brew upgrade magpie")
|
||||
}
|
||||
fmt.Println(muted.Render(" downloading " + update.BinaryAsset() + " …"))
|
||||
if err := update.ReplaceBinary(ctx, rel); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user