cargo fmt

This commit is contained in:
Trevor Bentley
2023-01-12 21:02:59 +01:00
parent 99cdc02af5
commit 51007c68b8
2 changed files with 20 additions and 17 deletions
+16 -15
View File
@@ -132,8 +132,9 @@ impl GitsyGenerator {
self.settings.outputs.path.display() self.settings.outputs.path.display()
)); ));
let canonical_path = PathBuf::from(path); let canonical_path = PathBuf::from(path);
let has_relative_dirs = canonical_path.ancestors().any(|x| x.file_name().is_none() && let has_relative_dirs = canonical_path
x != Path::new("/")); .ancestors()
.any(|x| x.file_name().is_none() && x != Path::new("/"));
assert!( assert!(
canonical_path.is_absolute(), canonical_path.is_absolute(),
"ERROR: write_rendered called with a relative path: {}", "ERROR: write_rendered called with a relative path: {}",
@@ -347,13 +348,14 @@ impl GitsyGenerator {
if let Some(templ_file) = self.settings.templates.branches.as_deref() { if let Some(templ_file) = self.settings.templates.branches.as_deref() {
let mut paged_ctx = local_ctx.clone(); let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("branches"); paged_ctx.remove("branches");
let pages = summary let pages = summary.branches.chunks(self.settings.paginate_branches());
.branches
.chunks(self.settings.paginate_branches());
let page_count = pages.len(); let page_count = pages.len();
for (idx, page) in pages.enumerate() { for (idx, page) in pages.enumerate() {
let pagination = let pagination = Pagination::new(
Pagination::new(idx + 1, page_count, &self.settings.outputs.branches(Some(&summary), None)); idx + 1,
page_count,
&self.settings.outputs.branches(Some(&summary), None),
);
paged_ctx.insert("page", &pagination.with_relative_paths()); paged_ctx.insert("page", &pagination.with_relative_paths());
paged_ctx.insert("branches", &page); paged_ctx.insert("branches", &page);
match tera.render(templ_file, &paged_ctx) { match tera.render(templ_file, &paged_ctx) {
@@ -389,9 +391,7 @@ impl GitsyGenerator {
if let Some(templ_file) = self.settings.templates.tags.as_deref() { if let Some(templ_file) = self.settings.templates.tags.as_deref() {
let mut paged_ctx = local_ctx.clone(); let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("tags"); paged_ctx.remove("tags");
let pages = summary let pages = summary.tags.chunks(self.settings.paginate_tags());
.tags
.chunks(self.settings.paginate_tags());
let page_count = pages.len(); let page_count = pages.len();
for (idx, page) in pages.enumerate() { for (idx, page) in pages.enumerate() {
let pagination = let pagination =
@@ -437,13 +437,14 @@ impl GitsyGenerator {
if let Some(templ_file) = self.settings.templates.history.as_deref() { if let Some(templ_file) = self.settings.templates.history.as_deref() {
let mut paged_ctx = local_ctx.clone(); let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("history"); paged_ctx.remove("history");
let pages = summary let pages = summary.history.chunks(self.settings.paginate_history());
.history
.chunks(self.settings.paginate_history());
let page_count = pages.len(); let page_count = pages.len();
for (idx, page) in pages.enumerate() { for (idx, page) in pages.enumerate() {
let pagination = let pagination = Pagination::new(
Pagination::new(idx + 1, page_count, &self.settings.outputs.history(Some(&summary), None)); idx + 1,
page_count,
&self.settings.outputs.history(Some(&summary), None),
);
paged_ctx.insert("page", &pagination.with_relative_paths()); paged_ctx.insert("page", &pagination.with_relative_paths());
paged_ctx.insert("history", &page); paged_ctx.insert("history", &page);
match tera.render(templ_file, &paged_ctx) { match tera.render(templ_file, &paged_ctx) {
+4 -2
View File
@@ -126,8 +126,10 @@ macro_rules! output_path_fn {
_ => tmpl_str, _ => tmpl_str,
}; };
let tmpl = PathBuf::from(tmpl_str); let tmpl = PathBuf::from(tmpl_str);
let mut path = self.path.clone().canonicalize() let mut path = self.path.clone().canonicalize().expect(&format!(
.expect(&format!("ERROR: unable to canonicalize output path: {}", self.path.display())); "ERROR: unable to canonicalize output path: {}",
self.path.display()
));
path.push(tmpl); path.push(tmpl);
match $is_dir { match $is_dir {
true => { true => {