Skip to content

Commit 326c9f5

Browse files
committed
review: use strict validator at IPC call sites; minor cleanup
Migrate electron/ipc/register.ts's loose validateBranchName (only rejected empty / leading "-") to the new shared validator from electron/mcp/validation, so the strict git-check-ref-format rules actually run today instead of waiting for later coordinator PRs. Drop the now-unused orphan exemption for validation.ts in .dependency-cruiser.cjs. Default the field name in validateBranchName to "branch" rather than the misleading "baseBranch". Comment .parallel-code/ in .gitignore.
1 parent f1949ca commit 326c9f5

4 files changed

Lines changed: 3 additions & 8 deletions

File tree

.dependency-cruiser.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ module.exports = {
5151
'^electron/mcp/server\\.ts$',
5252
// New subsystem files have no importers until coordinator PRs land
5353
'^electron/mcp/atomic\\.ts$',
54-
'^electron/mcp/validation\\.ts$',
5554
// Vite ambient env declarations
5655
'^src/vite-env\\.d\\.ts$',
5756
],

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dist-electron
44
dist-remote
55
release
66
coverage
7+
# Runtime data dir written by the app (MCP coordinator state, etc.)
78
.parallel-code/
89
.worktrees
910
.idea

electron/ipc/register.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import {
7777
assertOptionalString,
7878
assertOptionalBoolean,
7979
} from './validate.js';
80+
import { validateBranchName } from '../mcp/validation.js';
8081
import { warn as logWarn } from '../log.js';
8182

8283
function errMessage(err: unknown): string {
@@ -103,12 +104,6 @@ function validateRelativePath(p: unknown, label: string): void {
103104
if (p.includes('..')) throw new Error(`${label} must not contain ".."`);
104105
}
105106

106-
/** Reject branch names that could be misinterpreted as git flags. */
107-
function validateBranchName(name: unknown, label: string): void {
108-
if (typeof name !== 'string' || !name) throw new Error(`${label} must be a non-empty string`);
109-
if (name.startsWith('-')) throw new Error(`${label} must not start with "-"`);
110-
}
111-
112107
/** Reject commit hashes that are not valid hex strings. */
113108
function validateCommitHash(hash: unknown, label: string): void {
114109
if (typeof hash !== 'string') throw new Error(`${label} must be a string`);

electron/mcp/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Shared branch-name validator used by MCP, REST, and IPC paths.
22
// Conservative subset of git check-ref-format rules — no process spawn.
33

4-
export function validateBranchName(value: unknown, field = 'baseBranch'): string {
4+
export function validateBranchName(value: unknown, field = 'branch'): string {
55
if (typeof value !== 'string') throw new Error(`${field} must be a string`);
66
if (!value.trim()) throw new Error(`${field} must be a non-empty string`);
77
// git check-ref-format --branch rejects HEAD specifically; FETCH_HEAD etc. are accepted.

0 commit comments

Comments
 (0)