Skip to content

Commit

Permalink
fix(sdk): manage relative path starting with ./ (#7191)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored Oct 28, 2024
1 parent 716adf1 commit b4ae03e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdk/glob/glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ func Glob(cwd string, pattern string) (*FileResults, error) {
} else {
retaliveExpressions = append(retaliveExpressions, s)
}
if strings.HasPrefix(expression, "!") {
splittedExpression[i] = "!" + filepath.Clean(s)
} else {
splittedExpression[i] = filepath.Clean(s)
}

}

if len(absoluteExpressions) > 0 && len(retaliveExpressions) > 0 {
Expand Down
9 changes: 9 additions & 0 deletions sdk/glob/glob_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package glob

import (
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -152,3 +153,11 @@ func TestGlob_MatchFiles(t *testing.T) {
require.NoError(t, err)
t.Logf("%s matches %s", pattern, result.String())
}

func TestGlob_Relative(t *testing.T) {
pattern := "./path/to/artifacts/bar"
cwd := fmt.Sprintf("%s", os.DirFS("tests/fixtures"))
result, err := Glob(cwd, pattern)
require.NoError(t, err)
require.Equal(t, 1, len(result.Results))
}

0 comments on commit b4ae03e

Please sign in to comment.