diff options
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/by-name/ro/rollup/src/main.rs | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/pkgs/by-name/ro/rollup/src/main.rs b/pkgs/by-name/ro/rollup/src/main.rs index a2b661b1..cd91842a 100644 --- a/pkgs/by-name/ro/rollup/src/main.rs +++ b/pkgs/by-name/ro/rollup/src/main.rs @@ -6,6 +6,7 @@ use std::{ io::Write, path::{Path, PathBuf}, process::{Command, Stdio}, + sync::RwLock, }; use anyhow::{Context, Result, bail}; @@ -294,7 +295,7 @@ fn apply_patches( if applies_to.join(path).try_exists()? { bail!("A file was added, that already existed. This should be impossible.") } - if target_is_owning_path(&config.drop_ins, owner, &root, path)? { + if target_is_owning_path(&config.drop_ins, owner, &root, path, dry_run)? { final_diffs.push(file_diff.to_owned()); } } @@ -360,6 +361,16 @@ fn apply_patches( } } + if dry_run { + let ownerless_paths = PATHS_WITHOUT_OWNERSHIP.read().unwrap(); + if !ownerless_paths.is_empty() { + eprintln!("\n\nPaths without ownership information:"); + for path in &*ownerless_paths { + eprintln!(" - {}", path.display()); + } + } + } + Ok(()) } @@ -387,11 +398,14 @@ fn check_owner(owner: &Owner) -> Result<()> { Ok(()) } +static PATHS_WITHOUT_OWNERSHIP: RwLock<Vec<PathBuf>> = RwLock::new(vec![]); + fn target_is_owning_path( drop_ins: &HashMap<PathBuf, DropInConfig>, owner: &Owner, root: &Path, path: &Path, + dry_run: bool, ) -> Result<bool> { let file_name = path.file_name().expect("All paths are to files"); if file_name == OsStr::new(DROP_IN_NAME) || file_name == OsStr::new(MAIN_CONFIG_NAME) { @@ -440,10 +454,21 @@ fn target_is_owning_path( parent = next; } - eprintln!( - "Warning: There was no drop-in config defining path ownership for: `{}`. - Assuming inclusion.", - path.display() - ); - Ok(true) + if dry_run { + eprintln!( + "Warning: There was no drop-in config defining path ownership for: `{}`. + Assuming inclusion (only works for --dry-run).", + path.display() + ); + PATHS_WITHOUT_OWNERSHIP + .write() + .unwrap() + .push(path.to_owned()); + Ok(true) + } else { + bail!( + "There was no drop-in config defining path ownership for: `{}`.", + path.display() + ) + } } |
