From 454484516cad50f793f20891bbc44a07c1595b9f Mon Sep 17 00:00:00 2001 From: Ian Gregson Date: Thu, 23 May 2024 14:19:28 +0000 Subject: [PATCH] Fix an issue with using exclude on windows --- pkg/config/config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 41ef2441..31c5cdbc 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -708,8 +708,15 @@ func (c *Config) discoverRecursivePackages(ctx context.Context) error { subPkgCtx := subPkgLog.WithContext(pkgCtx) if len(conf.Exclude) > 0 { - p := pathlib.NewPath(subPkg) - relativePath, err := p.RelativeToStr(pkgPath) + // pass in the forward-slash as this is a package and the os.PathSeparator + // cannot be used here as it fails on windows. + p := pathlib.NewPath(subPkg, pathlib.PathWithSeperator("/")) + relativePath, err := p.RelativeTo( + pathlib.NewPath( + pkgPath, pathlib.PathWithAfero(p.Fs()), + pathlib.PathWithSeperator("/"), + ), + ) if err != nil { return stackerr.NewStackErrf(err, "failed to get path for %s relative to %s", subPkg, pkgPath) }