summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ro/rollup/src/main.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-04 20:29:45 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-11-05 22:47:43 +0100
commit26b46c743994788550ca90b916c6359c855bbba7 (patch)
tree14ccdd3e9637ee82415268413da6923b7437070b /pkgs/by-name/ro/rollup/src/main.rs
parentpkgs/rollup: Finish first mvp (diff)
downloadnixos-config-26b46c743994788550ca90b916c6359c855bbba7.zip
pkgs/rollup: Actually also parse renames in patches
Diffstat (limited to 'pkgs/by-name/ro/rollup/src/main.rs')
-rw-r--r--pkgs/by-name/ro/rollup/src/main.rs23
1 files changed, 17 insertions, 6 deletions
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(),
@@ -92,8 +92,19 @@ 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()
);
}
}