fix parent links when limit_context is specified
This commit is contained in:
+14
-1
@@ -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<String, GitObject> = 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,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="branch-page">
|
||||
<table class="branch-header">
|
||||
<tr class="header"><td class="field">branch:</td><td class="value">{{branch.ref_name}}</td></tr>
|
||||
<tr class="header"><td class="field">commit:</td><td class="value">{% if branch.full_hash in commits -%}<a href="{{repo_url | safe}}/commit/{{branch.full_hash}}.html">{{branch.full_hash}}</a>{% else -%}{{branch.full_hash}}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">commit:</td><td class="value">{% if branch.full_hash in commit_ids -%}<a href="{{repo_url | safe}}/commit/{{branch.full_hash}}.html">{{branch.full_hash}}</a>{% else -%}{{branch.full_hash}}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{branch.author.name}} <{{branch.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">committer:</td><td class="value">{{branch.committer.name}} <{{branch.committer.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=branch.ts_utc, tz=branch.ts_offset)}}</td></tr>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{commit.author.name}} <{{commit.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">committer:</td><td class="value">{{commit.committer.name}} <{{commit.committer.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=commit.ts_utc, tz=commit.ts_offset)}}</td></tr>
|
||||
<tr class="header"><td class="field">parents:</td><td class="value">{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commits -%}<a href="{{parent}}.html">{{parent}}</a>{%else-%}{{parent}}{%endif-%}{%-endfor-%}</td></tr>
|
||||
<tr class="header"><td class="field">parents:</td><td class="value">{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commit_ids -%}<a href="{{parent}}.html">{{parent}}</a>{%else-%}{{parent}}{%endif-%}{%-endfor-%}</td></tr>
|
||||
</table>
|
||||
<div class="commit-message">
|
||||
<pre style="margin: 0;">{{commit.message}}</pre>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<table class="tag-header">
|
||||
<tr class="header"><td class="field">tag:</td><td class="value">{{tag.ref_name}}</td></tr>
|
||||
<tr class="header"><td class="field">hash:</td><td class="value">{{tag.full_hash}}</td></tr>
|
||||
<tr class="header"><td class="field">tagged commit:</td><td class="value">{% if tag.tagged_id -%}{% if tag.tagged_id in commits -%}<a href="{{repo_url | safe}}/commit/{{tag.tagged_id}}.html">{{tag.tagged_id}}</a>{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">tagged commit:</td><td class="value">{% if tag.tagged_id -%}{% if tag.tagged_id in commit_ids -%}<a href="{{repo_url | safe}}/commit/{{tag.tagged_id}}.html">{{tag.tagged_id}}</a>{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{tag.author.name}} <{{tag.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=tag.ts_utc, tz=tag.ts_offset)}}</td></tr>
|
||||
</table>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<div class="branch-page">
|
||||
<table class="branch-header">
|
||||
<tr class="header"><td class="field">branch:</td><td class="value">{{branch.ref_name}}</td></tr>
|
||||
<tr class="header"><td class="field">commit:</td><td class="value">{% if branch.full_hash in commits -%}<a href="{{repo_url | safe}}/commit/{{branch.full_hash}}.html">{{branch.full_hash}}</a>{% else -%}{{branch.full_hash}}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">commit:</td><td class="value">{% if branch.full_hash in commit_ids -%}<a href="{{repo_url | safe}}/commit/{{branch.full_hash}}.html">{{branch.full_hash}}</a>{% else -%}{{branch.full_hash}}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{branch.author.name}} <{{branch.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">committer:</td><td class="value">{{branch.committer.name}} <{{branch.committer.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=branch.ts_utc, tz=branch.ts_offset)}}</td></tr>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{commit.author.name}} <{{commit.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">committer:</td><td class="value">{{commit.committer.name}} <{{commit.committer.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=commit.ts_utc, tz=commit.ts_offset)}}</td></tr>
|
||||
<tr class="header"><td class="field">parents:</td><td class="value">{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commits -%}<a href="{{parent}}.html">{{parent}}</a>{%else-%}{{parent}}{%endif-%}{%-endfor-%}</td></tr>
|
||||
<tr class="header"><td class="field">parents:</td><td class="value">{% for parent in commit.parents -%}{% if loop.index0 > 0 -%}, {%endif-%}{% if parent in commit_ids -%}<a href="{{parent}}.html">{{parent}}</a>{%else-%}{{parent}}{%endif-%}{%-endfor-%}</td></tr>
|
||||
</table>
|
||||
<div class="commit-message">
|
||||
<pre style="margin: 0;">{{commit.message}}</pre>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<table class="tag-header">
|
||||
<tr class="header"><td class="field">tag:</td><td class="value">{{tag.ref_name}}</td></tr>
|
||||
<tr class="header"><td class="field">hash:</td><td class="value">{{tag.full_hash}}</td></tr>
|
||||
<tr class="header"><td class="field">tagged commit:</td><td class="value">{% if tag.tagged_id -%}{% if tag.tagged_id in commits -%}<a href="{{repo_url | safe}}/commit/{{tag.tagged_id}}.html">{{tag.tagged_id}}</a>{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">tagged commit:</td><td class="value">{% if tag.tagged_id -%}{% if tag.tagged_id in commit_ids -%}<a href="{{repo_url | safe}}/commit/{{tag.tagged_id}}.html">{{tag.tagged_id}}</a>{% else -%}{{tag.tagged_id}}{% endif -%}{% endif -%}</td></tr>
|
||||
<tr class="header"><td class="field">author:</td><td class="value">{{tag.author.name}} <{{tag.author.email}}></td></tr>
|
||||
<tr class="header"><td class="field">date:</td><td class="value">{{ts_to_git_timestamp(ts=tag.ts_utc, tz=tag.ts_offset)}}</td></tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user