copy readme files to their real name in addition to the file hash

This commit is contained in:
Trevor Bentley
2025-01-15 00:01:36 +01:00
parent a99f2a72a3
commit fe81abfdac
3 changed files with 21 additions and 4 deletions
+17
View File
@@ -889,6 +889,23 @@ impl GitsyGenerator {
local_bytes = self.write_rendered(&out_path, &rendered);
atomic_repo_bytes.fetch_add(local_bytes, Ordering::SeqCst);
atomic_bytes.fetch_add(local_bytes, Ordering::SeqCst);
// Copy readme files to their real filename, so links to readme files remain valid
// across file changes.
if let Some(readmes) = &repo_desc.readme_files {
for readme in readmes {
if &file.path == readme {
let mut pretty_path = PathBuf::from(out_path);
pretty_path.pop();
pretty_path.push(&file.path);
match std::fs::copy(&out_path, &pretty_path) {
Ok(_) => louder!(" - wrote readme file: {}", pretty_path.to_string_lossy()),
Err(e) => error!("ERROR: {:?}", e),
}
}
}
};
}
Err(x) => match x.kind {
_ => error!("ERROR: {:?}", x),