diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..03c6b71
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+.github
+target/rls
+tests
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 01da084..e3ad57e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,6 +47,23 @@ where
mime_guess::from_path(path).first_or(mime::APPLICATION_OCTET_STREAM)
}
+fn paths
(
+ patterns: impl IntoIterator-
+) -> Result, Box>
+where
+ P: AsRef,
+{
+ patterns
+ .into_iter()
+ .try_fold(Vec::new(), |mut paths, pattern| {
+ let matched = glob::glob(pattern.as_ref())?
+ .filter_map(Result::ok)
+ .filter(|p| p.is_file());
+ paths.extend(matched);
+ Ok(paths)
+ })
+}
+
fn run(
conf: Config,
releaser: &dyn Releaser,
@@ -64,15 +81,7 @@ fn run(
)?;
if let Some(patterns) = conf.input_files {
- let paths: Result, Box> =
- patterns
- .into_iter()
- .try_fold(Vec::new(), |mut paths, pattern| {
- let matched = glob::glob(pattern.as_str())?.filter_map(Result::ok);
- paths.extend(matched);
- Ok(paths)
- });
- for path in paths? {
+ for path in paths(patterns)? {
log::info!("⬆️ Uploading asset {}", path.display());
uploader.upload(
conf.github_token.as_str(),
@@ -120,4 +129,13 @@ mod tests {
assert_eq!(is_tag(gitref), *expect)
}
}
+
+ #[test]
+ fn paths_resolves_pattern_to_file_paths() -> Result<(), Box> {
+ for p in paths(vec!["tests/data/**/*"])? {
+ println!("{}", p.display())
+ }
+ assert_eq!(paths(vec!["tests/data/**/*"])?.into_iter().count(), 1);
+ Ok(())
+ }
}
diff --git a/tests/data/foo/bar.txt b/tests/data/foo/bar.txt
new file mode 100644
index 0000000..4efd442
--- /dev/null
+++ b/tests/data/foo/bar.txt
@@ -0,0 +1 @@
+release me
\ No newline at end of file