GITv

Align repository tree columns and display UK dates

Browse files
Author
Um9i vulgarmessiah@gmail.com
Date
22 Nov 2026, 14:15
Commit
50964bd9b6f8
Parent
007725c

5 files changed +33−13

@@ -255,14 +255,17 @@ button.button{cursor:pointer}
a.entry,.repo-row,.tabs a,.button,.segmented a,.refmenu summary,.menu a{transition:background-color .12s,border-color .12s,color .12s}
}
.tree-row{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,3fr) max-content;align-items:center;column-gap:12px;padding-right:16px}
.tree-list{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,3fr) max-content;column-gap:12px}
.tree-list>li{grid-column:1/-1}
.tree-row{display:grid;grid-template-columns:subgrid;align-items:center}
.tree-row time{margin-right:16px}
.tree-row:hover,.tree-row:focus-within{background:var(--sunk)}
.tree-row .entry{min-width:0}
.entry-commit{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-2)}
.entry-commit:hover,.entry-commit:focus-visible{color:var(--accent);text-decoration:underline}
.tree-row time{justify-self:end;white-space:nowrap;color:var(--ink-2);font-size:13px}
@media(max-width:650px){
.tree-row{grid-template-columns:minmax(0,1fr) max-content}
.tree-list{grid-template-columns:minmax(0,1fr) max-content}
.tree-row time{grid-column:2;grid-row:1}
.entry-commit{grid-column:1/-1;padding:0 0 8px 42px;font-size:13px}
}
@@ -346,7 +346,7 @@ struct Head {
}
impl Head {
/// Parse `%H %an %ct %cs %s`, separated by 0x1f. The subject goes last and the split stops
/// Parse `%H %an %ct %cd %s`, separated by 0x1f. The subject goes last and the split stops
/// at five fields, so a subject that itself contains the separator byte stays whole.
fn parse(out: &str) -> Option<Head> {
let f: Vec<&str> = out.trim_end_matches('\n').splitn(5, '\x1f').collect();
@@ -526,7 +526,9 @@ impl Repo {
fn latest_raw(&self, rev: &str, path: &[u8]) -> Option<String> {
let lookup = || {
let mut args: Vec<&OsStr> =
["log", "-1", "--format=%H%x1f%an%x1f%ct%x1f%cs%x1f%s", rev, "--"].map(OsStr::new).to_vec();
["log", "-1", "--date=format:%-d %b %Y", "--format=%H%x1f%an%x1f%ct%x1f%cd%x1f%s", rev, "--"]
.map(OsStr::new)
.to_vec();
if !path.is_empty() {
args.push(OsStr::from_bytes(path));
}
@@ -545,20 +547,30 @@ impl Repo {
fn entry_commit(&self, commit: &str, path: &[u8]) -> Option<templates::EntryCommit> {
let key = self.key("entry-commit", commit, &encode(path));
let record = cached(key, || {
let args = ["log", "-1", "--format=%H%x00%ct%x00%cI%x00%s%x00%B", commit, "--"].map(OsStr::new);
let args = [
"log",
"-1",
"--date=format:%-d %b %Y, %H:%M:%S %z",
"--format=%H%x00%ct%x00%cI%x00%cd%x00%s%x00%B",
commit,
"--",
]
.map(OsStr::new);
self.git(&[args.as_slice(), &[OsStr::from_bytes(path)]].concat()).filter(|out| !out.is_empty())
})?;
let mut fields = record.splitn(5, '\0');
let mut fields = record.splitn(6, '\0');
let oid = fields.next()?;
let stamp = fields.next()?;
let datetime = fields.next()?;
let full_date = fields.next()?;
let subject = subject_or_placeholder(fields.next()?);
let message = fields.next()?.trim_end();
Some(templates::EntryCommit {
url: self.url("commit", &[("id", oid)]),
subject: subject.into(),
message: if message.is_empty() { subject } else { message }.into(),
when: ago(stamp, datetime.split('T').next().unwrap_or(datetime)),
when: ago(stamp, full_date.split(',').next().unwrap_or(full_date)),
full_date: full_date.into(),
datetime: datetime.into(),
})
}
@@ -902,7 +914,7 @@ fn view_tree(repo: &Repo, q: &Q) -> Option<View> {
ago(&head.stamp, &head.date)
);
}
body += r#"<ul class="rows">"#;
body += r#"<ul class="rows tree-list">"#;
if !path.is_empty() {
let up = repo.url_at("tree", &reference, parent_of(&path), "");
let _ = write!(
@@ -1096,7 +1108,8 @@ fn view_log(repo: &Repo, q: &Q) -> Option<View> {
"log",
&format!("-n{}", PAGE + 1),
&format!("--skip={skip}"),
"--format=%H%x1f%an%x1f%ct%x1f%cs%x1f%s",
"--date=format:%-d %b %Y",
"--format=%H%x1f%an%x1f%ct%x1f%cd%x1f%s",
&commit,
"--",
])?;
@@ -1340,7 +1353,7 @@ fn view_tags(repo: &Repo) -> Option<View> {
let out = repo.git(&[
"for-each-ref",
"--sort=-creatordate",
"--format=%(refname:lstrip=2)%1f%(objectname)%1f%(*objectname)%1f%(creatordate:unix)%1f%(creatordate:short)%1f%(objecttype)%1f%(contents:subject)",
"--format=%(refname:lstrip=2)%1f%(objectname)%1f%(*objectname)%1f%(creatordate:unix)%1f%(creatordate:format:%-d %b %Y)%1f%(objecttype)%1f%(contents:subject)",
"refs/tags",
])?;
let mut rows = String::new();
@@ -52,6 +52,7 @@ pub(super) struct EntryCommit {
pub message: String,
pub when: String,
pub datetime: String,
pub full_date: String,
}
#[derive(Template)]
@@ -6,6 +6,6 @@
{% endif %}
{% if let Some(change) = commit %}
<a class="entry-commit" href="{{ change.url }}" title="{{ change.message }}">{{ change.subject }}</a>
<time datetime="{{ change.datetime }}" title="{{ change.datetime }}">{{ change.when }}</time>
<time datetime="{{ change.datetime }}" title="{{ change.full_date }}">{{ change.when }}</time>
{% endif %}
</li>
@@ -361,7 +361,10 @@ fn tree_rows_link_each_entry_to_its_own_change() {
.find(|row| row.contains(&format!(">{name}<")))
.unwrap();
assert!(row.contains(&format!("/ada/site/commit?id={oid}")), "{row}");
assert!(row.contains(message) && row.contains("<time datetime="), "{row}");
assert!(
row.contains(message) && row.contains("title=\"2 Jan 2026, 03:04:05 +0000\">2 Jan 2026</time>"),
"{row}"
);
}
}
@@ -498,7 +501,7 @@ fn history_lists_commits_with_tags_and_pages() {
assert_eq!(order.len(), 5);
assert!(order.windows(2).all(|w| w[0] < w[1]), "out of order: {order:?}");
assert!(html.contains(">v0.1.0</a>") && html.contains(">light</a>"), "tag chips");
assert!(html.contains("Ada Lovelace committed 2026-01-02"));
assert!(html.contains("Ada Lovelace committed 2 Jan 2026"));
assert!(!html.contains(">Older<"), "one page is enough for main");
let first = s.get("/ada/site/log?ref=long").text();