Skip to content

Commit 2a92862

Browse files
MackinnonBuckCopilot
authored andcommitted
fix: address review comments - valuePascal initialisms, Phase 2 regex, add pr/ado
- valuePascal now uses goInitialisms so 'url' -> 'URL', 'mcp' -> 'MCP', etc. - Phase 2 regex uses [\s\S]*? to match multi-line func bodies - Added 'pr' and 'ado' to goInitialisms Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ec5938 commit 2a92862

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

go/generated_session_events.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/codegen/go.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const execFileAsync = promisify(execFile);
2727
// ── Utilities ───────────────────────────────────────────────────────────────
2828

2929
// Go initialisms that should be all-caps
30-
const goInitialisms = new Set(["id", "url", "api", "http", "https", "json", "xml", "html", "css", "sql", "ssh", "tcp", "udp", "ip", "rpc", "mcp"]);
30+
const goInitialisms = new Set(["id", "url", "api", "http", "https", "json", "xml", "html", "css", "sql", "ssh", "tcp", "udp", "ip", "rpc", "mcp", "pr", "ado"]);
3131

3232
function toPascalCase(s: string): string {
3333
return s
@@ -60,9 +60,10 @@ function postProcessEnumConstants(code: string): string {
6060
const [, constName, typeName, value] = m;
6161
if (constName.startsWith(typeName)) continue;
6262

63+
// Use the same initialism logic as toPascalCase so "url" → "URL", "mcp" → "MCP", etc.
6364
const valuePascal = value
6465
.split(/[._-]/)
65-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
66+
.map((w) => goInitialisms.has(w.toLowerCase()) ? w.toUpperCase() : w.charAt(0).toUpperCase() + w.slice(1))
6667
.join("");
6768
const desired = typeName + valuePascal;
6869
if (constName !== desired) {
@@ -82,9 +83,8 @@ function postProcessEnumConstants(code: string): string {
8283
return b;
8384
});
8485

85-
// Phase 2: Rename inside func bodies that reference the enum constants
86-
// (marshal/unmarshal helpers generated by quicktype use case statements)
87-
code = code.replace(/^(func \(.*?\n\})/gm, (funcBlock) => {
86+
// Phase 2: Rename inside func bodies (marshal/unmarshal helpers use case statements)
87+
code = code.replace(/^(func \([\s\S]*?\n\})/gm, (funcBlock) => {
8888
let b = funcBlock;
8989
for (const [oldName, newName] of renames) {
9090
b = b.replace(new RegExp(`\\b${oldName}\\b`, "g"), newName);

0 commit comments

Comments
 (0)