From 26b46c743994788550ca90b916c6359c855bbba7 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Wed, 4 Nov 2026 20:29:45 +0100 Subject: pkgs/rollup: Actually also parse renames in patches --- pkgs/by-name/ro/rollup/src/main.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'pkgs/by-name/ro/rollup/src/main.rs') diff --git a/pkgs/by-name/ro/rollup/src/main.rs b/pkgs/by-name/ro/rollup/src/main.rs index 48b395a5..f49eb81e 100644 --- a/pkgs/by-name/ro/rollup/src/main.rs +++ b/pkgs/by-name/ro/rollup/src/main.rs @@ -7,7 +7,7 @@ use std::{ use anyhow::{Context, Result, bail}; use clap::Parser; -use crate::parse::Patch; +use crate::parse::{FileDiff, Patch}; mod parse; @@ -64,13 +64,13 @@ fn main() -> Result<()> { let mut final_diffs = vec![]; for file_diff in &patch.files { match file_diff { - parse::FileDiff::Add { path, .. } => { + FileDiff::Add { path, .. } => { if args.to.join(path).exists() { bail!("A file was added, that already existed. This should be impossible.") } final_diffs.push(file_diff.to_owned()); } - parse::FileDiff::Remove { path, .. } => { + FileDiff::Remove { path, .. } => { if args.to.join(path).exists() { final_diffs.push(file_diff.to_owned()); } else { @@ -80,9 +80,9 @@ fn main() -> Result<()> { ); } } - parse::FileDiff::Change { from, to, .. } => { + FileDiff::Rename { from, to, .. } => { if args.to.join(from).exists() { - if from != to && args.to.join(to).exists() { + if args.to.join(to).exists() { bail!( "A rename (`{}` -> `{}`) tried to rename a path to an already existing path. This should be impossible.", from.display(), @@ -90,10 +90,21 @@ fn main() -> Result<()> { ) } final_diffs.push(file_diff.to_owned()); + } else { + eprintln!( + "Dropping rename from `{}` to `{}`, as the from file does not exist in the rollup target.", + from.display(), + to.display() + ); + } + } + FileDiff::Change { path, .. } => { + if args.to.join(path).exists() { + final_diffs.push(file_diff.to_owned()); } else { eprintln!( "Dropping change to `{}`, as the file does not exist in the rollup target.", - from.display() + path.display() ); } } -- cgit v1.3.1