Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions e2e/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,31 @@ func TestUndev_basic(t *testing.T) {
}
}

func TestUndev_preservesExecutableBit(t *testing.T) {
home := setupHome(t)
mpDir := newMarketplace(t, home, "test-mp", []pluginSpec{{"hello", "0.1.0"}})
script := filepath.Join(mpDir, "plugins", "hello", "scripts", "run.sh")
if err := os.MkdirAll(filepath.Dir(script), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(script, []byte("#!/bin/sh\n"), 0o755); err != nil {
t.Fatal(err)
}
installPlugin(t, home, "hello@test-mp")
src := newPluginSource(t, "hello", "0.1.0")

mustCplugins(t, home, "dev", "hello@test-mp", src)
mustCplugins(t, home, "undev", "hello@test-mp")

fi, err := os.Stat(filepath.Join(installPath(t, home, "hello@test-mp"), "scripts", "run.sh"))
if err != nil {
t.Fatalf("script missing from the recached plugin: %v", err)
}
if fi.Mode().Perm()&0o111 == 0 {
t.Errorf("script mode = %v, want executable", fi.Mode().Perm())
}
}

func TestUndev_notInDevMode(t *testing.T) {
home := setupHome(t)
newMarketplace(t, home, "test-mp", []pluginSpec{{"hello", "0.1.0"}})
Expand Down
12 changes: 11 additions & 1 deletion internal/cache/recache.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,20 @@ func copyDir(src, dst string) error {
_ = os.Remove(dstPath)
return os.Symlink(target, dstPath)
}
info, err := d.Info()
if err != nil {
return err
}
data, err := os.ReadFile(path)
if err != nil {
return err
}
return os.WriteFile(dstPath, data, 0o644)
// A read-only file left by a previous copy would make WriteFile fail.
_ = os.Remove(dstPath)
if err := os.WriteFile(dstPath, data, info.Mode().Perm()); err != nil {
return err
}
// WriteFile's mode goes through the umask.
return os.Chmod(dstPath, info.Mode().Perm())
})
}
Loading