Skip to content

Commit

Permalink
fix: allow glob patterns in task outputs and sources (#2285) (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdickinson committed Jun 15, 2024
1 parent f01cc8d commit bd64408
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ filetime = "0.2.23"
flate2 = "1.0.30"
fslock = "0.2.1"
git2 = "0.18.3"
glob = "0.3.1"
globset = "0.4.14"
globwalk = "0.9.1"
heck = "0.5"
home = "0.5.9"
humantime = "2.1.0"
Expand Down
26 changes: 19 additions & 7 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use demand::{DemandOption, Select};
use duct::IntoExecutablePath;
use either::Either;
use eyre::{bail, ensure, eyre, Result};
use globwalk::GlobWalkerBuilder;
use glob::glob;
use itertools::Itertools;
use once_cell::sync::Lazy;

Expand Down Expand Up @@ -479,7 +479,7 @@ impl Run {

fn is_glob_pattern(path: &str) -> bool {
// This is the character set used for glob
// detection by globwalk
// detection by glob
let glob_chars = ['*', '{', '}'];

path.chars().any(|c| glob_chars.contains(&c))
Expand Down Expand Up @@ -512,12 +512,24 @@ fn last_modified_glob_match(
if patterns.is_empty() {
return Ok(None);
}
let files = GlobWalkerBuilder::from_patterns(root, patterns)
.follow_links(true)
.build()?
let files = patterns
.iter()
.flat_map(|pattern| {
glob(
root.as_ref()
.join(pattern)
.to_str()
.expect("Conversion to string path failed"),
)
.unwrap()
})
.filter_map(|e| e.ok())
.filter(|e| e.file_type().is_file())
.map(|e| e.path().to_owned());
.filter(|e| {
e.metadata()
.expect("Metadata call failed")
.file_type()
.is_file()
});

last_modified_file(files)
}
Expand Down

0 comments on commit bd64408

Please sign in to comment.