diff --git a/src/generate.rs b/src/generate.rs index 28c8664..97d4bc1 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -22,7 +22,7 @@ */ use crate::{ error, - git::{dir_listing, parse_repo, GitFile, GitRepo, GitsyMetadata}, + git::{dir_listing, parse_repo, GitFile, GitObject, GitRepo, GitsyMetadata}, loud, louder, loudest, normal, normal_noln, settings::{GitsyCli, GitsyRepoDescriptions, GitsySettings, GitsySettingsRepo}, template::{ @@ -34,6 +34,7 @@ use chrono::{DateTime, Local}; use git2::{Error, Repository}; use rayon::prelude::*; use std::cmp; +use std::collections::BTreeMap; use std::fs::File; use std::io::Write; use std::path::{Path, PathBuf}; @@ -443,14 +444,26 @@ impl GitsyGenerator { .try_for_each(|(idx, page)| { let mut paged_ctx = ctx.clone(); let pagination = Pagination::new(idx + 1, page_count, &out_path); + // make sure the 'commits' map contains the same + // commits as the current page. + let commits: BTreeMap = page + .iter() + .map(|entry| match parsed_repo.commits.get(&entry.full_hash) { + Some(com) => Some((entry.full_hash.clone(), com.clone())), + _ => None, + }) + .map_while(|x| x) + .collect(); paged_ctx.insert("page", &pagination.with_relative_paths()); paged_ctx.insert("history", &page); + paged_ctx.insert("commits", &commits); let rendered = tera.render(templ_path, &paged_ctx)?; let bytes = self.write_rendered(&pagination.cur_page, &rendered); repo_bytes.fetch_add(bytes, Ordering::SeqCst); atomic_bytes.fetch_add(bytes, Ordering::SeqCst); paged_ctx.remove("page"); paged_ctx.remove("history"); + paged_ctx.remove("commits"); size_check_atomic!( repo_desc, atomic_bytes, diff --git a/templates/default_dark/branch.html b/templates/default_dark/branch.html index 6c6ee14..e949d31 100644 --- a/templates/default_dark/branch.html +++ b/templates/default_dark/branch.html @@ -6,7 +6,7 @@
- + diff --git a/templates/default_dark/commit.html b/templates/default_dark/commit.html index 89982ed..44eb4d3 100644 --- a/templates/default_dark/commit.html +++ b/templates/default_dark/commit.html @@ -9,7 +9,7 @@ - +
branch:{{branch.ref_name}}
commit:{% if branch.full_hash in commits -%}{{branch.full_hash}}{% else -%}{{branch.full_hash}}{% endif -%}
commit:{% if branch.full_hash in commit_ids -%}{{branch.full_hash}}{% else -%}{{branch.full_hash}}{% endif -%}
author:{{branch.author.name}} <{{branch.author.email}}>
committer:{{branch.committer.name}} <{{branch.committer.email}}>
date:{{ts_to_git_timestamp(ts=branch.ts_utc, tz=branch.ts_offset)}}
author:{{commit.author.name}} <{{commit.author.email}}>
committer:{{commit.committer.name}} <{{commit.committer.email}}>
date:{{ts_to_git_timestamp(ts=commit.ts_utc, tz=commit.ts_offset)}}
parents:{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commits -%}{{parent}}{%else-%}{{parent}}{%endif-%}{%-endfor-%}
parents:{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commit_ids -%}{{parent}}{%else-%}{{parent}}{%endif-%}{%-endfor-%}
{{commit.message}}
diff --git a/templates/default_dark/tag.html b/templates/default_dark/tag.html index 5178118..b9e1b58 100644 --- a/templates/default_dark/tag.html +++ b/templates/default_dark/tag.html @@ -7,7 +7,7 @@ - +
tag:{{tag.ref_name}}
hash:{{tag.full_hash}}
tagged commit:{% if tag.tagged_id -%}{% if tag.tagged_id in commits -%}{{tag.tagged_id}}{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}
tagged commit:{% if tag.tagged_id -%}{% if tag.tagged_id in commit_ids -%}{{tag.tagged_id}}{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}
author:{{tag.author.name}} <{{tag.author.email}}>
date:{{ts_to_git_timestamp(ts=tag.ts_utc, tz=tag.ts_offset)}}
diff --git a/templates/default_light/branch.html b/templates/default_light/branch.html index 6c6ee14..e949d31 100644 --- a/templates/default_light/branch.html +++ b/templates/default_light/branch.html @@ -6,7 +6,7 @@
- + diff --git a/templates/default_light/commit.html b/templates/default_light/commit.html index 89982ed..44eb4d3 100644 --- a/templates/default_light/commit.html +++ b/templates/default_light/commit.html @@ -9,7 +9,7 @@ - +
branch:{{branch.ref_name}}
commit:{% if branch.full_hash in commits -%}{{branch.full_hash}}{% else -%}{{branch.full_hash}}{% endif -%}
commit:{% if branch.full_hash in commit_ids -%}{{branch.full_hash}}{% else -%}{{branch.full_hash}}{% endif -%}
author:{{branch.author.name}} <{{branch.author.email}}>
committer:{{branch.committer.name}} <{{branch.committer.email}}>
date:{{ts_to_git_timestamp(ts=branch.ts_utc, tz=branch.ts_offset)}}
author:{{commit.author.name}} <{{commit.author.email}}>
committer:{{commit.committer.name}} <{{commit.committer.email}}>
date:{{ts_to_git_timestamp(ts=commit.ts_utc, tz=commit.ts_offset)}}
parents:{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commits -%}{{parent}}{%else-%}{{parent}}{%endif-%}{%-endfor-%}
parents:{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commit_ids -%}{{parent}}{%else-%}{{parent}}{%endif-%}{%-endfor-%}
{{commit.message}}
diff --git a/templates/default_light/tag.html b/templates/default_light/tag.html index 5178118..b9e1b58 100644 --- a/templates/default_light/tag.html +++ b/templates/default_light/tag.html @@ -7,7 +7,7 @@ - +
tag:{{tag.ref_name}}
hash:{{tag.full_hash}}
tagged commit:{% if tag.tagged_id -%}{% if tag.tagged_id in commits -%}{{tag.tagged_id}}{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}
tagged commit:{% if tag.tagged_id -%}{% if tag.tagged_id in commit_ids -%}{{tag.tagged_id}}{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}
author:{{tag.author.name}} <{{tag.author.email}}>
date:{{ts_to_git_timestamp(ts=tag.ts_utc, tz=tag.ts_offset)}}