The best way to control Claude Code, Codex and more from any computer or phone
fix(git): bound merge credit parsing work (#37869)
Julius Marminge committed
Nov 17, 2026 at 01:36 UTC
f1cd57bbf9572a592bed46f69dae57c9b10e4848
2 files changed
+29
-13
packages/source-control-core/src/server/mergeMessage.test.ts
+1
@@ -14,6 +14,7 @@ describe("removeAgentCredits", () => {
14
"* Co-authored-by: Codex <noreply@openai.com>",
15
"co-authored-by: Cursor <cursoragent@cursor.com>",
16
"Co-authored-by: Copilot <copilot@github.com>",
17
+ "Co-Authored-By:\tGitHub Copilot <NOREPLY@GITHUB.COM>",
18
"",
19
"🤖 Generated with [Claude Code](https://claude.ai/code)",
20
].join("\n"),
packages/source-control-core/src/server/mergeMessage.ts
+28
-13
@@ -11,6 +11,22 @@ const AGENT_EMAILS = new Set([
11
const GENERATED_BY_AGENT =
12
/^(?:🤖\s*)?generated (?:with|by)\s+(?:claude(?: code)?|codex|cursor|github copilot|copilot|opencode|grok|antigravity)[.!]?$/i;
13
14
+const CO_AUTHOR_PREFIX = /^co-authored-by:/i;
15
+
16
+function isAgentAuthor(text: string): boolean {
17
+ const prefix = CO_AUTHOR_PREFIX.exec(text);
18
+ if (prefix === null || !text.endsWith(">")) return false;
19
+ const emailStart = text.lastIndexOf("<");
20
+ if (emailStart < prefix[0].length) return false;
21
+ const email = text.slice(emailStart + 1, -1).toLowerCase();
22
+ if (!AGENT_EMAILS.has(email)) return false;
23
+ // GitHub's generic noreply address is also used by people; require Copilot's name.
24
+ return (
25
+ email !== "noreply@github.com" ||
26
+ /^(?:github )?copilot$/i.test(text.slice(prefix[0].length, emailStart).trim())
27
+ );
28
+}
29
+
30
export function removeAgentCredits(message: string): string {
31
let fence: string | undefined;
32
let removed = false;
@@ -34,20 +50,19 @@ export function removeAgentCredits(message: string): string {
50
}
51
if (fence !== undefined) return true;
52
const text = line.trim().replace(/^(?:[-*]\s+)/, "");
37
- const author = /^co-authored-by:\s*(.*?)\s*<([^<>]+)>\s*$/i.exec(text);
38
- // GitHub's generic noreply address is also used by people; require Copilot's name.
39
- const email = author?.[2]?.toLowerCase();
40
- const agentAuthor =
41
- email !== undefined &&
42
- AGENT_EMAILS.has(email) &&
43
- (email !== "noreply@github.com" || /^github copilot$|^copilot$/i.test(author![1]!));
44
- const footer = text.replace(
45
- /\[([^\]]+)\]\(https:\/\/(?:claude\.ai|claude\.com|www\.anthropic\.com|chatgpt\.com|openai\.com|cursor\.com|github\.com|opencode\.ai|x\.ai|antigravity\.google)(?:\/[^\s)]*)?\)/gi,
46
- "$1",
47
- );
48
- if (!agentAuthor && !GENERATED_BY_AGENT.test(footer)) return true;
53
+ if (!isAgentAuthor(text)) {
54
+ const footer = text.replace(
55
+ /\[([^[\]\r\n]+)\]\(https:\/\/(?:claude\.ai|claude\.com|www\.anthropic\.com|chatgpt\.com|openai\.com|cursor\.com|github\.com|opencode\.ai|x\.ai|antigravity\.google)(?:\/[^\s)[\]]*)?\)/gi,
56
+ "$1",
57
+ );
58
+ if (!GENERATED_BY_AGENT.test(footer)) return true;
59
+ }
60
removed = true;
61
return false;
62
});
52
- return removed ? lines.join(newline).replace(/(?:\r?\n[ \t]*)+$/, "") : message;
63
+ if (!removed) return message;
64
+ while (lines.length > 1 && /^[ \t]*$/.test(lines.at(-1)!)) {
65
+ lines.pop();
66
+ }
67
+ return lines.join(newline);
68
}