Skip to content

Commit

Permalink
refactor: simplify re-init of exclude filter
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Dec 5, 2023
1 parent 5e0fbd0 commit 358850f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 3 additions & 6 deletions core/src/vcs/git-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@ const getIncludeExcludeFiles: IncludeExcludeFilesHandler<GitRepoGetFilesParams,
params
) => {
const { include, path, scanFromProjectRoot } = params
let { exclude } = params

if (!exclude) {
exclude = []
}

// Make sure action config is not mutated.
let exclude = !params.exclude ? [] : [...params.exclude]

// Do the same normalization of the excluded paths like in GitHandler.
// This might be redundant because the non-normalized paths will be handled by augmentGlobs below.
// But this brings no harm and makes the implementation more clear.
exclude = [...exclude.map(normalize)]
exclude = exclude.map(normalize)

// We allow just passing a path like `foo` as include and exclude params
// Those need to be converted to globs, but we don't want to touch existing globs
Expand Down
8 changes: 3 additions & 5 deletions core/src/vcs/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ interface GitSubTreeIncludeExcludeFiles extends BaseIncludeExcludeFiles {
const getIncludeExcludeFiles: IncludeExcludeFilesHandler<GetFilesParams, GitSubTreeIncludeExcludeFiles> = async (
params: GetFilesParams
) => {
let { include, exclude } = params

if (!exclude) {
exclude = []
}
let include = params.include

// Make sure action config is not mutated.
let exclude = !params.exclude ? [] : [...params.exclude]

// It looks like paths with redundant '.' and '..' parts
// do not work well along with --exclude and --glob-pathspecs flags.
exclude = [...exclude.map(normalize), "**/.garden/**/*"]
Expand Down

0 comments on commit 358850f

Please sign in to comment.