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()
));
let canonical_path = PathBuf::from(path);
let has_relative_dirs = canonical_path.ancestors().any(|x| x.file_name().is_none() &&
x != Path::new("/"));
let has_relative_dirs = canonical_path
.ancestors()
.any(|x| x.file_name().is_none() && x != Path::new("/"));
assert!(
canonical_path.is_absolute(),
"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() {
let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("branches");
let pages = summary
.branches
.chunks(self.settings.paginate_branches());
let pages = summary.branches.chunks(self.settings.paginate_branches());
let page_count = pages.len();
for (idx, page) in pages.enumerate() {
let pagination =
Pagination::new(idx + 1, page_count, &self.settings.outputs.branches(Some(&summary), None));
let pagination = Pagination::new(
idx + 1,
page_count,
&self.settings.outputs.branches(Some(&summary), None),
);
paged_ctx.insert("page", &pagination.with_relative_paths());
paged_ctx.insert("branches", &page);
match tera.render(templ_file, &paged_ctx) {
@@ -389,9 +391,7 @@ impl GitsyGenerator {
if let Some(templ_file) = self.settings.templates.tags.as_deref() {
let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("tags");
let pages = summary
.tags
.chunks(self.settings.paginate_tags());
let pages = summary.tags.chunks(self.settings.paginate_tags());
let page_count = pages.len();
for (idx, page) in pages.enumerate() {
let pagination =
@@ -437,13 +437,14 @@ impl GitsyGenerator {
if let Some(templ_file) = self.settings.templates.history.as_deref() {
let mut paged_ctx = local_ctx.clone();
paged_ctx.remove("history");
let pages = summary
.history
.chunks(self.settings.paginate_history());
let pages = summary.history.chunks(self.settings.paginate_history());
let page_count = pages.len();
for (idx, page) in pages.enumerate() {
let pagination =
Pagination::new(idx + 1, page_count, &self.settings.outputs.history(Some(&summary), None));
let pagination = Pagination::new(
idx + 1,
page_count,
&self.settings.outputs.history(Some(&summary), None),
);
paged_ctx.insert("page", &pagination.with_relative_paths());
paged_ctx.insert("history", &page);
match tera.render(templ_file, &paged_ctx) {
+4 -2
View File
@@ -126,8 +126,10 @@ macro_rules! output_path_fn {
_ => tmpl_str,
};
let tmpl = PathBuf::from(tmpl_str);
let mut path = self.path.clone().canonicalize()
.expect(&format!("ERROR: unable to canonicalize output path: {}", self.path.display()));
let mut path = self.path.clone().canonicalize().expect(&format!(
"ERROR: unable to canonicalize output path: {}",
self.path.display()
));
path.push(tmpl);
match $is_dir {
true => {