// c31 — model: pure helpers for shaping a git commit out of an edit // submission. Source-agnostic — used to live with c14_forgejo's // commitFile, now feeds c14_git.commitFile against the local bare // repo. Sibling-tested. export interface CommitMessageInput { // Page title shown in the editor header (e.g. "S — Sorted"). title: string; // GitHub login of the admin who saved the edit. author: string; // Path under repo root, e.g. "content/sama/sorted.md". filePath: string; } // One-line subject + author trailer. Intentionally short so it reads // well in `git log --oneline` and in the Forgejo commit list. export const buildCommitMessage = (input: CommitMessageInput): string => { const subject = `edit ${input.filePath} via web`; const trailer = `\n\nSubmitted by ${input.author} via the tdd.md self-hosted editor.`; return subject + trailer; }; // GitHub-style noreply email so commits attribute to the user's // GitHub account in tools that link by email. Mirrors the logic in // c21_handlers_auth where we mint Forgejo identities. export const noreplyEmail = (login: string, githubId?: number): string => githubId !== undefined ? `${githubId}+${login}@users.noreply.github.com` : `${login}@users.noreply.github.com`;