mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
fix(winget): replace forward slashes in Winget RelativeFilePath
(#4195)
If an archive filename contains `/` characters, they can sneak into Winget's `RelativeFilePath`. In this PR, I make sure that `RelativeFilePath` only uses `\` directory separators.
This commit is contained in:
parent
ca1657c2ec
commit
00bc248c1b
internal/pipe/winget
6
internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden
vendored
6
internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden
vendored
@ -9,21 +9,21 @@ Installers:
|
||||
- Architecture: x64
|
||||
NestedInstallerType: portable
|
||||
NestedInstallerFiles:
|
||||
- RelativeFilePath: foo\foo.exe
|
||||
- RelativeFilePath: foo\bin\foo.exe
|
||||
InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_amd64v1.zip
|
||||
InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
UpgradeBehavior: uninstallPrevious
|
||||
- Architecture: x86
|
||||
NestedInstallerType: portable
|
||||
NestedInstallerFiles:
|
||||
- RelativeFilePath: foo\foo.exe
|
||||
- RelativeFilePath: foo\bin\foo.exe
|
||||
InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_386.zip
|
||||
InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
UpgradeBehavior: uninstallPrevious
|
||||
- Architecture: arm64
|
||||
NestedInstallerType: portable
|
||||
NestedInstallerFiles:
|
||||
- RelativeFilePath: foo\foo.exe
|
||||
- RelativeFilePath: foo\bin\foo.exe
|
||||
InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_arm64.zip
|
||||
InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
UpgradeBehavior: uninstallPrevious
|
||||
|
@ -224,7 +224,7 @@ func (p Pipe) doRun(ctx *context.Context, winget config.Winget, cl client.Releas
|
||||
folder := artifact.ExtraOr(*archive, artifact.ExtraWrappedIn, ".")
|
||||
for _, bin := range artifact.ExtraOr(*archive, artifact.ExtraBinaries, []string{}) {
|
||||
files = append(files, InstallerItemFile{
|
||||
RelativeFilePath: windowsJoin([2]string{folder, bin}),
|
||||
RelativeFilePath: strings.ReplaceAll(filepath.Join(folder, bin), "/", "\\"),
|
||||
})
|
||||
}
|
||||
url, err := tmpl.New(ctx).WithArtifact(archive).Apply(winget.URLTemplate)
|
||||
@ -397,10 +397,3 @@ func extFor(tp artifact.Type) string {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func windowsJoin(elem [2]string) string {
|
||||
if elem[0] == "" {
|
||||
return elem[1]
|
||||
}
|
||||
return elem[0] + "\\" + elem[1]
|
||||
}
|
||||
|
@ -602,15 +602,24 @@ func TestRunPipe(t *testing.T) {
|
||||
goarch := "amd64"
|
||||
createFakeArtifact("partial", goos, goarch, "v1", "", nil)
|
||||
createFakeArtifact("foo", goos, goarch, "v1", "", nil)
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "v1", "", map[string]any{artifact.ExtraWrappedIn: "foo"})
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "v1", "", map[string]any{
|
||||
artifact.ExtraWrappedIn: "foo",
|
||||
artifact.ExtraBinaries: []string{"bin/foo.exe"},
|
||||
})
|
||||
|
||||
goarch = "386"
|
||||
createFakeArtifact("foo", goos, goarch, "", "", nil)
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{artifact.ExtraWrappedIn: "foo"})
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{
|
||||
artifact.ExtraWrappedIn: "foo",
|
||||
artifact.ExtraBinaries: []string{"bin/foo.exe"},
|
||||
})
|
||||
|
||||
goarch = "arm64"
|
||||
createFakeArtifact("foo", goos, goarch, "", "", nil)
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{artifact.ExtraWrappedIn: "foo"})
|
||||
createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{
|
||||
artifact.ExtraWrappedIn: "foo",
|
||||
artifact.ExtraBinaries: []string{"bin/foo.exe"},
|
||||
})
|
||||
|
||||
client := client.NewMock()
|
||||
pipe := Pipe{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user