From d76a46b37b12823b5b3976d129c2d4b672a99693 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Tue, 11 Aug 2026 08:37:25 -0400 Subject: Show the build's commit in the page footer Workers can't shell out at request time, so the commit has to be baked in before wrangler bundles the sources. compile-views.ts grows a second job and becomes scripts/build.ts: alongside the precompiled views it writes src/commit.generated.ts with `git describe --tags --always --dirty`, which yields a bare short hash until the repo is tagged and marks builds made from an unclean working copy. Co-Authored-By: Claude Opus 5 --- src/app.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/app.ts') diff --git a/src/app.ts b/src/app.ts index 5bed45d..0218918 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,6 +1,7 @@ import type { Eta } from "eta"; import { type Context, Hono } from "hono"; import type { StatusCode } from "hono/utils/http-status"; +import { commit } from "./commit.generated.ts"; import { getGitHubBlob, getGitHubCommits, @@ -47,7 +48,7 @@ export function createApp(eta: Eta) { // Our URLs mirror GitHub's, so the page we scraped is the same path there. const { pathname, search } = new URL(c.req.url); const githubUrl = `https://github.com${pathname}${search}`; - return c.html(eta.render(template, { ...data, githubUrl })); + return c.html(eta.render(template, { ...data, githubUrl, commit })); } // For fragments fetched asynchronously by client-side JS (see public/static/refs.js): -- cgit v1.3.1