From e83357833d543413cb0256f4a74879653110bc7f Mon Sep 17 00:00:00 2001 From: 6543 Date: Wed, 1 Nov 2023 11:29:44 +0100 Subject: [PATCH] Use path.Join for server side path generation (#2689) make sure to have valid config even when server is running under windows --- *Sponsored by Kithara Software GmbH* --- pipeline/frontend/yaml/compiler/convert.go | 5 ++--- pipeline/frontend/yaml/compiler/option.go | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index 994da63dd..9ee729075 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -18,7 +18,6 @@ import ( "fmt" "maps" "path" - "path/filepath" "strings" "github.com/google/uuid" @@ -212,8 +211,8 @@ func (c *Compiler) createProcess(name string, container *yaml_types.Container, s } func (c *Compiler) stepWorkdir(container *yaml_types.Container) string { - if filepath.IsAbs(container.Directory) { + if path.IsAbs(container.Directory) { return container.Directory } - return filepath.Join(c.base, c.path, container.Directory) + return path.Join(c.base, c.path, container.Directory) } diff --git a/pipeline/frontend/yaml/compiler/option.go b/pipeline/frontend/yaml/compiler/option.go index d451ef6b4..bd8355358 100644 --- a/pipeline/frontend/yaml/compiler/option.go +++ b/pipeline/frontend/yaml/compiler/option.go @@ -16,7 +16,7 @@ package compiler import ( "net/url" - "path/filepath" + "path" "strings" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata" @@ -105,12 +105,12 @@ func WithWorkspace(base, path string) Option { // WithWorkspaceFromURL configures the compiler with the workspace // base and path based on the repository url. func WithWorkspaceFromURL(base, link string) Option { - path := "src" + srcPath := "src" parsed, err := url.Parse(link) if err == nil { - path = filepath.Join(path, parsed.Hostname(), parsed.Path) + srcPath = path.Join(srcPath, parsed.Hostname(), parsed.Path) } - return WithWorkspace(base, path) + return WithWorkspace(base, srcPath) } // WithEscalated configures the compiler to automatically execute