Skip to content

Commit

Permalink
fix(tasks): leading slash not required in user-given blob patterns in…
Browse files Browse the repository at this point in the history
… PushNamespaceFiles
  • Loading branch information
brian-mulier-p committed May 31, 2024
1 parent c34d213 commit ab54872
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/io/kestra/plugin/git/PushNamespaceFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.runners.NamespaceFilesService;
import io.kestra.core.runners.RunContext;
import io.kestra.core.utils.PathUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
Expand Down Expand Up @@ -141,11 +142,11 @@ protected Map<Path, Supplier<InputStream>> instanceResourcesContentByPath(RunCon
null
).stream();
if (globs != null) {
List<PathMatcher> matchers = globs.stream().map(glob -> FileSystems.getDefault().getPathMatcher("glob:" + glob)).toList();
List<PathMatcher> matchers = globs.stream().map(glob -> FileSystems.getDefault().getPathMatcher("glob:" + PathUtil.checkLeadingSlash(glob))).toList();
uriStream = uriStream.filter(uri ->
{
Path path = Path.of(uri.getPath());
return matchers.stream().anyMatch(matcher -> matcher.matches(path) || matcher.matches(path.getFileName()));
return matchers.stream().anyMatch(matcher -> matcher.matches(path) || matcher.matches(Path.of(PathUtil.checkLeadingSlash(path.getFileName().toString()))));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void defaultCase_SingleRegex() throws Exception {
.authorEmail("{{email}}")
.authorName("{{name}}")
.namespace("{{namespace}}")
.files("second*")
.files("nested/*")
.gitDirectory("{{gitDirectory}}")
.build();

Expand Down

0 comments on commit ab54872

Please sign in to comment.