{"draft":null,"from":175,"to":318,"files":[{"path":"client/src/git-origin.ts","added":90,"removed":0,"diff":"--- /dev/null\n+++ b/client/src/git-origin.ts\n@@ -0,0 +1,90 @@\n+// Where a push came from in git, when it was imported (abso-core issue 21).\n+// A version imported by client/scripts/import-git.ts ends its message with\n+// a line naming the commit, its author and its time, and, when the\n+// repository's issues are on the web, a line saying where:\n+//\n+//   git 4e1a7c2b9f03, Ada Lovelace, 2026-10-06T20:36:43-05:00\n+//   Issues: https://github.com/owner/repo/issues\n+//\n+// A commit pushed with plain git ends with \"Git-Commit: <sha>\" and\n+// \"Author: <name>\". A host may also name the commit beside the version\n+// (`commit`). Issue references like \"#39\" in an imported message, or in a\n+// line it wrote, mean that repository's issues, not the project's.\n+\n+export interface GitOrigin {\n+\treadonly commit: string;\n+\treadonly author?: string;\n+\treadonly time?: string;\n+\t/** The repository's issues, as a web address, when known. */\n+\treadonly issues?: string;\n+\t/** The message with these lines taken off. */\n+\treadonly message: string;\n+}\n+\n+const IMPORTED = /^git ([0-9a-f]{7,64}), (.+), (\\d{4}-\\d\\d-\\d\\dT[^,\\s]+)$/;\n+const ISSUES = /^Issues: (https?:\\/\\/\\S+)$/;\n+const PUSHED = /^Git-Commit: ([0-9a-f]{7,64})$/;\n+const PUSHED_BY = /^Author: (.+)$/;\n+\n+/**\n+ * A push's git origin, from its message's last lines or the commit its host\n+ * names, or undefined when it didn't come from git. `issues` is where \"#N\"\n+ * points when the message doesn't say (the project's \"gitIssues\").\n+ */\n+export function gitOrigin(\n+\tp: { readonly message: string; readonly commit?: string; readonly author?: string },\n+\tissues?: string,\n+): GitOrigin | undefined {\n+\tconst lines = p.message.trimEnd().split(\"\\n\");\n+\tlet end = lines.length;\n+\tlet found: Omit<GitOrigin, \"message\"> | undefined;\n+\tconst tracker = ISSUES.exec(lines[end - 1] ?? \"\");\n+\tif (tracker) end--;\n+\tconst imported = IMPORTED.exec(lines[end - 1] ?? \"\");\n+\tif (imported) {\n+\t\tend--;\n+\t\tfound = { commit: imported[1]!, author: imported[2]!, time: imported[3]! };\n+\t} else {\n+\t\tconst by = PUSHED_BY.exec(lines[end - 1] ?? \"\");\n+\t\tconst sha = PUSHED.exec(lines[end - (by ? 2 : 1)] ?? \"\");\n+\t\tif (sha) {\n+\t\t\tend -= by ? 2 : 1;\n+\t\t\tfound = { commit: sha[1]!, ...(by ? { author: by[1]! } : {}) };\n+\t\t}\n+\t}\n+\tif (!found && p.commit !== undefined) found = { commit: p.commit, ...(p.author ? { author: p.author } : {}) };\n+\tif (!found) return undefined;\n+\tconst where = tracker?.[1] ?? issues;\n+\treturn {\n+\t\t...found,\n+\t\t...(where ? { issues: where.replace(/\\/+$/, \"\") } : {}),\n+\t\tmessage: lines.slice(0, end).join(\"\\n\").trimEnd(),\n+\t};\n+}\n+\n+/** A git remote's issues on the web: GitHub's or GitLab's, by https or ssh; else undefined. */\n+export function issuesOf(remote: string): string | undefined {\n+\tconst plain = remote\n+\t\t.trim()\n+\t\t.replace(/\\/+$/, \"\")\n+\t\t.replace(/\\.git$/, \"\");\n+\tconst m = /^(?:https:\\/\\/|ssh:\\/\\/git@|git@)(github\\.com|gitlab\\.com)[:/]([\\w.-]+(?:\\/[\\w.-]+)+)$/.exec(plain);\n+\tif (!m) return undefined;\n+\treturn m[1] === \"gitlab.com\" ? `https://gitlab.com/${m[2]}/-/issues` : `https://github.com/${m[2]}/issues`;\n+}\n+\n+/** The issues \"#N\" names in text, each once, in order: not \"owner/repo#N\", which names its own. */\n+export function issueNumbers(text: string): number[] {\n+\tconst out: number[] = [];\n+\tfor (const m of text.matchAll(/(^|[^\\w/])#(\\d+)\\b/g)) {\n+\t\tconst n = Number(m[2]);\n+\t\tif (!out.includes(n)) out.push(n);\n+\t}\n+\treturn out;\n+}\n+\n+/** One line per \"#N\" in text, saying which tracker it's in. Empty without a tracker or a reference. */\n+export function issueLinks(text: string, issues: string | undefined): string[] {\n+\tif (!issues) return [];\n+\treturn issueNumbers(text).map((n) => `#${n} is ${issues}/${n}`);\n+}"}],"unmatched":[]}