Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

localinfra: add script to validate commit messages

Signed-off-by: Spenser Black <me@spenser.black>

Spenser Black (Jul 12, 2026, 1:45 PM EDT) f35d05fe 2adda573

+22
+22
localinfra/scripts/git-hooks/commit-msg.js
··· 1 + #!/usr/bin/env node 2 + const fs = require("node:fs"); 3 + // This hook receives the path to the temporary commit message file as its one and only 4 + // positional argument. 5 + const msg = fs.readFileSync(process.argv[2], { encoding: "utf-8" }); 6 + 7 + // NOTE While technically possible that the very first line would be a comment, this 8 + // should be unlikely enough that we can safely test the first line. 9 + const title = /^([^\n]+)(?:\n|$)/.exec(msg)?.[1] || ""; 10 + if (/^[A-Z]/.test(title) || /:\s[A-Z]/.test(title)) { 11 + console.error("Commit message titles should be in lowercase"); 12 + process.exitCode = 1; 13 + } 14 + if (!/.+:\s[^\n]+/.test(msg)) { 15 + console.error("First line should be in the format `<service/top-level directory>/<affected package/directory>: <short summary of change>`"); 16 + process.exitCode = 1; 17 + } 18 + 19 + if (!/\nSigned-off-by:/.test(msg)) { 20 + console.error("Commits must be signed-off (use `git commit -s` to add the sign-off trailer)"); 21 + process.exitCode = 1; 22 + }