From f691b128f428f0856194e729433f1f39f10b7771 Mon Sep 17 00:00:00 2001 From: TheAwesome98 Date: Fri, 16 Feb 2024 19:25:55 +0000 Subject: [PATCH] add commit info --- .gitignore | 1 + prebuild.js | 28 +++++++++++++++++++++++++++- src/_includes/layouts/main.njk | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 72f8f7f..bfff472 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,4 @@ www/ # things for compile time data src/static/images/88x31/3rdparty src/_data/gd.json +src/_data/buildinfo.json diff --git a/prebuild.js b/prebuild.js index d4e9a01..b68130e 100644 --- a/prebuild.js +++ b/prebuild.js @@ -26,7 +26,15 @@ for (let set of eightyeightbythirtyones) { let url = new URL(button.src); client .get( - { hostname: url.hostname, path: url.pathname + url.search, headers: { "User-Agent": "Mozilla/5.0" } }, + { + hostname: url.hostname, + path: url.pathname + url.search, + headers: { + "User-Agent": `tauon.dev-prebuild-fetcher/${ + require("./package.json").version + } node-http/${process.versions.node} `, + }, + }, (res) => { let outfile = "src/static/images/88x31/3rdparty/" + @@ -68,3 +76,21 @@ let gd = new GD(); } filesystem.writeFileSync("src/_data/gd.json", JSON.stringify(userinfo)); })(); + +const spawn = require("child_process").spawn; +const proc = spawn("git", ["log", "-n", "1", '--pretty=format:"%h%n%s%n%ad"']); + +let output = ""; +proc.stdout.on("data", (chunk) => { + output += chunk.toString(); +}); +proc.on("exit", () => { + let [hash, message, dateRaw] = output.slice(1, -1).split(/\r\n|\r|\n/g); + let data = { + hash, + message, + commitDate: new Date(dateRaw), + buildDate: new Date(), + }; + filesystem.writeFileSync("src/_data/buildinfo.json", JSON.stringify(data)); +}); diff --git a/src/_includes/layouts/main.njk b/src/_includes/layouts/main.njk index 8ec7995..3fe04dd 100644 --- a/src/_includes/layouts/main.njk +++ b/src/_includes/layouts/main.njk @@ -176,6 +176,9 @@ +
+
compiled at {{ buildinfo.buildDate }} - git commit hash {{ buildinfo.hash }} - {{ buildinfo.message }} (at {{ buildinfo.commitDate }})
+
it seems that your browser is based on chromium technologies! you should install a free browser such as firefox to stop google taking over the web! (they have tried already...)