Files
yetone 8bf98110b8 plugin: a folder plugin's path written on macOS or Linux is a path on Windows too, so a backup or a sync leaves it out (#2229, JasonBuildAI)
plugin.IsPath read a spec as a path when filepath.IsAbs said so on the
host. On Windows "/Users/me/plugin" is not absolute, so a folder plugin
added on a Mac was carried into a backup and a WebDAV sync as if it were
an npm package, and the Windows machine restoring it asked bun to install
"/Users/me/plugin". A spec starting with / or \ (a UNC path among them)
now counts as a path on every system, as a drive-rooted one already did
off Windows.

Run:
- TestIsPathWhicheverSystemWroteIt (new). On the Windows box at the old
  code it fails for "/Users/me/plugin", "/home/me/plugin/index.js" and
  `\Users\me\plugin`; on macOS for the two backslash forms. Passes on both
  with the change.
- On the Windows box, the three reds the issue names, old code then new:
  TestPluginsCarried (provider), TestRestorePluginsAndSignIn (backup),
  TestSyncPluginsAndSignIn (davsync) FAIL then PASS.
- go test -tags nogui ./... on macOS with this and the next four commits:
  every package ok.
- gofmt -l, go vet ./... on darwin, linux (nogui) and windows, and the
  three builds: clean.
- Windows internal/plugin as a whole: TestTaggedRepos, TestTaggedReposSlowRead,
  TestReadmeOfTaggedRepo, TestGitPluginUpdateOnlyWhenItsRepositoryMoved,
  TestMarketIconsAreBundled, TestEnsurePi and TestGitPlugin fail there
  with and without the change (Windows-only, CI compiles them only).
  TestLoadConcurrentWithSavesAndEdits failed once in the full package run
  with the change; alone it passed 6 of 6 at the old code and 6 of 6 with
  it. Noted on #1827, the open issue for Windows-only reds.
2026-10-15 03:34:58 +08:00

29 lines
1.1 KiB
Go

package plugin
import "testing"
// #2229: plugins.json travels between machines in a backup or a sync, so
// a folder plugin's path written on macOS or Linux is a path on Windows
// too, and a Windows one is a path off Windows, or the restoring machine
// asks bun to install it as an npm package.
func TestIsPathWhicheverSystemWroteIt(t *testing.T) {
for spec, want := range map[string]bool{
"/Users/me/plugin": true,
"/home/me/plugin/index.js": true,
`\Users\me\plugin`: true,
`\\server\share\plugin`: true,
`C:\plugins\x`: true,
"D:/plugins/x": true,
"file:///Users/me/plugin": true,
"./my-plugin.js": true,
"opencode-gemini-auth": false,
"@magpie-community/opencode-kiro-auth": false,
"owner/repo": false,
"github:owner/repo": false,
} {
if got := IsPath(spec); got != want {
t.Errorf("IsPath(%q) = %v, want %v", spec, got, want)
}
}
}