summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ro
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ro')
-rw-r--r--pkgs/by-name/ro/rollup/src/main.rs12
-rw-r--r--pkgs/by-name/ro/rollup/src/parse.rs66
2 files changed, 74 insertions, 4 deletions
diff --git a/pkgs/by-name/ro/rollup/src/main.rs b/pkgs/by-name/ro/rollup/src/main.rs
index cd91842a..0150ca4b 100644
--- a/pkgs/by-name/ro/rollup/src/main.rs
+++ b/pkgs/by-name/ro/rollup/src/main.rs
@@ -339,6 +339,16 @@ fn apply_patches(
);
}
}
+ FileDiff::ModeChange { path, .. } => {
+ if applies_to.join(path).try_exists()? {
+ final_diffs.push(file_diff.to_owned());
+ } else {
+ drop_msg!(
+ "Dropping mode change to `{}`, as the file does not exist in the rollup target.",
+ path.display()
+ );
+ }
+ }
}
}
@@ -439,7 +449,7 @@ fn target_is_owning_path(
if !conf.owners.contains(&owner.name) {
// eprintln!(", but it's for `{}`, so ignoring path.", conf.owner);
drop_msg!(
- "Dropping `{}` as `{}` says this dir is for `{}` (but we look for `{}`).",
+ "Dropping creation of `{}` as `{}` says this dir is for `{}` (but we look for `{}`).",
path.display(),
next.join(DROP_IN_NAME).display(),
conf.owners.join(", "),
diff --git a/pkgs/by-name/ro/rollup/src/parse.rs b/pkgs/by-name/ro/rollup/src/parse.rs
index 05ef2cb6..a636d661 100644
--- a/pkgs/by-name/ro/rollup/src/parse.rs
+++ b/pkgs/by-name/ro/rollup/src/parse.rs
@@ -60,6 +60,11 @@ pub(crate) enum FileDiff {
diff: String,
index: String,
},
+ ModeChange {
+ path: PathBuf,
+ old_mode: String,
+ new_mode: String,
+ },
}
impl fmt::Display for FileDiff {
@@ -120,6 +125,15 @@ impl fmt::Display for FileDiff {
writeln!(f, "+++ b/{}", to.display())?;
writeln!(f, "{}", diff)?;
}
+ FileDiff::ModeChange {
+ path,
+ old_mode,
+ new_mode,
+ } => {
+ writeln!(f, "diff --git a/{} b/{}", path.display(), path.display())?;
+ writeln!(f, "old mode {}", old_mode)?;
+ writeln!(f, "new mode {}", new_mode)?;
+ }
}
Ok(())
@@ -159,13 +173,31 @@ macro_rules! parser {
.. $diff:ident
) => {
$(
- let $prefix_var = {
- let next = $iterator.next().unwrap();
+ let next = {
+ let next = $iterator
+ .next()
+ .expect(
+ concat!(
+ "iterator '",
+ stringify!($iterator),
+ "' did not have a next value"
+ )
+ );
if $debug {
eprintln!(" {}", next);
}
next
- }.strip_prefix($prefix).unwrap().to_owned();
+ };
+
+ let $prefix_var = next
+ .strip_prefix($prefix)
+ .expect(
+ format!(
+ "expected prefix `{}` in line `{}`, but didn't find it.",
+ $prefix,
+ next
+ ).as_str()
+ ).to_owned();
$(
$expr
)*;
@@ -299,6 +331,8 @@ pub(crate) fn parse_file(file: &Path, debug: bool) -> Result<Patch> {
// skip one more to go over the `---` line
.skip(1)
.peekable();
+ let mut git_diff_a = None;
+ let mut git_diff_b = None;
while let Some(line) = iterator.peek() {
if debug {
eprintln!("{}", line);
@@ -314,6 +348,16 @@ pub(crate) fn parse_file(file: &Path, debug: bool) -> Result<Patch> {
if skipping_frontmatter {
skipping_frontmatter = false;
}
+
+ {
+ let mut parts = line.split(' ');
+ assert_eq!("diff", parts.next().unwrap());
+ assert_eq!("--git", parts.next().unwrap());
+ git_diff_a = Some(parts.next().unwrap().strip_prefix("a/").unwrap());
+ git_diff_b = Some(parts.next().unwrap().strip_prefix("b/").unwrap());
+ assert_eq!(None, parts.next());
+ }
+
iterator.next().unwrap();
continue;
}
@@ -393,6 +437,22 @@ pub(crate) fn parse_file(file: &Path, debug: bool) -> Result<Patch> {
deleted_mode,
})
}
+ line if line.starts_with("old mode") => {
+ parser! {
+ iterator, debug,
+ "old mode " @ old_mode => {()};
+ "new mode " @ new_mode => {()};
+ ..no_diff
+ }
+ assert!(no_diff.is_empty());
+
+ assert_eq!(git_diff_a, git_diff_b);
+ patch_files.push(FileDiff::ModeChange {
+ path: PathBuf::from(git_diff_a.expect("Should have been produced by git")),
+ old_mode,
+ new_mode,
+ })
+ }
line if *line == "--" || *line == "-- " => {
final_whitespace = Some(match *line {
"-- " => " ",