git-finalizer 2.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,552 @@
1
+ """State-aware single-pass CLI parser for Git Finalizer.
2
+
3
+ Prevents flag hijacking via option values (e.g. `--message --repo-plan`,
4
+ `--message --summary`, `--run-id --summary`) and prevents `--version`/`--help`
5
+ combined with `--summary` from emitting a fabricated success summary.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import dataclasses
11
+
12
+ from git_finalizer import __version__
13
+
14
+ VALUE_FLAGS = frozenset(
15
+ {
16
+ "--mode",
17
+ "--repo",
18
+ "--message",
19
+ "-m",
20
+ "--remote",
21
+ "--remote-branch",
22
+ "--source-remote",
23
+ "--expected-target-oid",
24
+ "--snapshot",
25
+ "--allow-test-fixture",
26
+ "--fixture-exceptions",
27
+ "--allow-large-binary",
28
+ "--reviewed-sensitive-source",
29
+ "--merge-parent",
30
+ "--publish-existing-branch",
31
+ "--publish-existing-history",
32
+ "--resume-existing-history-publish",
33
+ "--resume-publish",
34
+ "--resume-initial-publish",
35
+ "--sync-published-branch",
36
+ "--publish-integration-candidate",
37
+ "--retire-remote-branch",
38
+ "--retire-local-branch",
39
+ "--expected-remote-oid",
40
+ "--expected-local-oid",
41
+ "--expected-integrated-oid",
42
+ "--integrated-into",
43
+ "--retirement-plan-id",
44
+ "--ci-status",
45
+ "--ci-commit-oid",
46
+ "--ci-verification-source",
47
+ "--ci-verified-at",
48
+ "--lease-id",
49
+ "--run-id",
50
+ "--gitea-url",
51
+ "--owner",
52
+ "--repo-name",
53
+ "--visibility",
54
+ "--remote-scheme",
55
+ "--timeout",
56
+ "--repository-id",
57
+ "--allocation-id",
58
+ "--task-key",
59
+ "--authority-key",
60
+ "--worktree-path",
61
+ "--role",
62
+ "--trailer-agent",
63
+ "--trace-ref",
64
+ "--scanner",
65
+ "--sarif-cmd",
66
+ "--opa-policy",
67
+ "--opa-query",
68
+ }
69
+ )
70
+
71
+ BOOLEAN_FLAGS = frozenset(
72
+ {
73
+ "--help",
74
+ "-h",
75
+ "--version",
76
+ "-V",
77
+ "--dry-run",
78
+ "--summary",
79
+ "--diagnostics",
80
+ "--initial-publish",
81
+ "--initial-commit-only",
82
+ "--initial-branch-publish",
83
+ "--repo-plan",
84
+ "--repo-ensure",
85
+ "--add-origin",
86
+ "--allow-insecure-http",
87
+ "--ci-required",
88
+ "--agent-trace",
89
+ }
90
+ )
91
+
92
+
93
+ @dataclasses.dataclass
94
+ class ParsedCLI:
95
+ raw_argv: list[str]
96
+ dispatch: str = "core" # "version" | "help" | "bootstrap" | "integration_publish" | "core"
97
+ mode: str = "normal" # normalized summary mode name
98
+ action: str = "normal" # specific CLI sub-action (e.g. resume-publish vs resume-initial-publish)
99
+ repo: str | None = None
100
+ message: str | None = None
101
+ remote: str | None = None
102
+ remote_branch: str | None = None
103
+ source_remote: str | None = None
104
+ expected_target_oid: str | None = None
105
+ snapshot: str | None = None
106
+ allow_test_fixtures: list[str] = dataclasses.field(default_factory=list)
107
+ fixture_exceptions: str | None = None
108
+ allow_large_binary: str | None = None
109
+ reviewed_sensitive_source: str | None = None
110
+ merge_parent: str | None = None
111
+ head_oid: str | None = None
112
+ retire_branch: str | None = None
113
+ expected_remote_oid: str | None = None
114
+ expected_local_oid: str | None = None
115
+ expected_integrated_oid: str | None = None
116
+ integrated_into: str = "main"
117
+ retirement_plan_id: str | None = None
118
+ ci_required: bool = False
119
+ ci_status: str | None = None
120
+ ci_commit_oid: str | None = None
121
+ ci_verification_source: str = "not_required"
122
+ ci_verification_source_seen: bool = False
123
+ ci_verified_at: str | None = None
124
+ dry_run: bool = False
125
+ summary: bool = False
126
+ diagnostics: bool = False
127
+ repository_id: str | None = None
128
+ allocation_id: str | None = None
129
+ task_key: str | None = None
130
+ authority_key: str | None = None
131
+ worktree_path: str | None = None
132
+ role: str | None = None
133
+ trailer_agent: str | None = None
134
+ trace_ref: str | None = None
135
+ agent_trace: bool = False
136
+ scanners: list[str] = dataclasses.field(default_factory=list)
137
+ sarif_cmd: str | None = None
138
+ opa_policy: str | None = None
139
+ opa_query: str = "data.git_finalizer.delivery.deny"
140
+ paths: list[str] = dataclasses.field(default_factory=list)
141
+ unknown_flags: list[str] = dataclasses.field(default_factory=list)
142
+ parse_error: str | None = None
143
+
144
+
145
+ def usage_text() -> str:
146
+ return f"""git-finalize {__version__}
147
+
148
+ Usage:
149
+ git-finalize --mode verify-only --repo <repo> [--diagnostics] [--merge-parent <oid>] [--reviewed-sensitive-source <file>] [--] <path>...
150
+ git-finalize --mode commit-only --repo <repo> --message <msg> [--reviewed-sensitive-source <file>] [--] <path>...
151
+ git-finalize --repo <repo> --message <msg> [--summary] [--] <path>...
152
+ git-finalize --initial-publish --remote <remote> --repo <repo> --message <msg> [--snapshot <64hex>] [--] <path>...
153
+ git-finalize --initial-commit-only --repo <repo> --message <msg> [--] <path>...
154
+ git-finalize --initial-branch-publish --remote <remote> --remote-branch <branch> --repo <repo> --message <msg> [--] <path>...
155
+ git-finalize --publish-existing-branch <oid> --remote <remote> --remote-branch <branch> --repo <repo> [--fixture-exceptions <file>] [--allow-large-binary <path>] [--reviewed-sensitive-source <file>]
156
+ git-finalize --publish-existing-history <oid> --remote <remote> --remote-branch <branch> --repo <repo> [--fixture-exceptions <file>] [--allow-large-binary <path>]
157
+ git-finalize --resume-publish <oid> --repo <repo> [--fixture-exceptions <file>] [--reviewed-sensitive-source <file>]
158
+ git-finalize --resume-initial-publish <oid> --remote <remote> --repo <repo> [--allow-test-fixture <path>]
159
+ git-finalize --resume-existing-history-publish <oid> --remote <remote> --remote-branch <branch> --repo <repo>
160
+ git-finalize --sync-published-branch <oid> --source-remote <src> --remote <dst> --remote-branch <branch> --expected-target-oid <oid> --repo <repo>
161
+ git-finalize --publish-integration-candidate <oid> --repo <candidate> --lease-id <id> --run-id <run> [--summary]
162
+ git-finalize --retire-remote-branch <branch> --remote <remote> --integrated-into <ref> --expected-remote-oid <oid> --expected-integrated-oid <oid> --retirement-plan-id <64hex> --repo <repo>
163
+ git-finalize --retire-local-branch <branch> --remote <remote> --integrated-into <ref> --expected-local-oid <oid> --expected-integrated-oid <oid> --retirement-plan-id <64hex> --repo <repo>
164
+ git-finalize --repo-plan --repo <repo> --gitea-url <url> --owner <owner> --repo-name <name> --visibility <private|public> [--summary]
165
+ git-finalize --repo-ensure --repo <repo> --gitea-url <url> --owner <owner> --repo-name <name> --visibility <private|public> [--add-origin] [--summary]
166
+
167
+ Options:
168
+ --mode <normal|verify-only|commit-only> Execution mode
169
+ --repo <path> Absolute or resolved Git worktree root
170
+ --message <text>, -m <text> Commit message
171
+ --remote <name> Target remote name
172
+ --remote-branch <name> Target remote branch name
173
+ --source-remote <name> Source remote for --sync-published-branch
174
+ --expected-target-oid <oid> Expected target remote OID for sync
175
+ --snapshot <64hex> Snapshot Runner diff-audit ID (initial-publish only)
176
+ --allow-test-fixture <path> Exact synthetic test fixture path under tests/
177
+ --fixture-exceptions <file> Exact reviewed fixture exception manifest JSON
178
+ --allow-large-binary <path> Exact binary blob override (5 MiB .. 25 MiB)
179
+ --reviewed-sensitive-source <file> External reviewed sensitive source manifest JSON
180
+ --merge-parent <oid> Second parent OID for resolved two-parent merge
181
+ --summary Emit single-line deterministic JSON summary
182
+ --diagnostics Include bounded runtime and scanner diagnostics in summary
183
+ --dry-run Validate without mutating Git state or remotes
184
+ --trailer-agent <name> Add Assisted-by AI provenance Git trailer
185
+ --trace-ref <uri> Add Agent-Trace-Ref Git trailer
186
+ --agent-trace Write Agent Trace JSON note to refs/notes/agent-trace
187
+ --scanner <gitleaks|trufflehog|osv|sarif-cmd> Run pluggable SARIF 2.1.0 external scanner
188
+ --sarif-cmd <exe> Executable for --scanner sarif-cmd
189
+ --opa-policy <path> Optional OPA Rego policy file or directory
190
+ --opa-query <query> OPA evaluation query (default: data.git_finalizer.delivery.deny)
191
+ --ci-verified-at <timestamp> CI verification timestamp metadata for branch retirement
192
+ --repository-id <id> Controller repository identity metadata
193
+ --allocation-id <id> Controller allocation identity metadata
194
+ --task-key <key> Controller task key metadata
195
+ --authority-key <key> Controller authority key metadata
196
+ --worktree-path <path> Controller worktree path metadata
197
+ --role <role> Controller worktree role metadata
198
+ --version, -V Print version and exit
199
+ --help, -h Print this help message and exit
200
+ """
201
+
202
+
203
+ def parse_cli(argv: list[str]) -> ParsedCLI:
204
+ """Parse CLI arguments left-to-right in a single state-aware pass."""
205
+ parsed = ParsedCLI(raw_argv=list(argv))
206
+ exclusive_actions: list[str] = []
207
+ explicit_mode_flag = False
208
+ seen_flags: set[str] = set()
209
+ repeatable_flags = {"--allow-test-fixture", "--scanner"}
210
+
211
+ idx = 0
212
+ total = len(argv)
213
+ while idx < total:
214
+ token = argv[idx]
215
+ if token == "--":
216
+ parsed.paths.extend(argv[idx + 1 :])
217
+ break
218
+
219
+ flag = token
220
+ inline_value: str | None = None
221
+ if token.startswith("--") and "=" in token:
222
+ flag, _, inline_value = token.partition("=")
223
+
224
+ if flag in {"--version", "-V"}:
225
+ if inline_value is not None:
226
+ parsed.parse_error = f"选项 {flag} 不接受参数值"
227
+ parsed.dispatch = "version"
228
+ idx += 1
229
+ continue
230
+ if flag in {"--help", "-h"}:
231
+ if inline_value is not None:
232
+ parsed.parse_error = f"选项 {flag} 不接受参数值"
233
+ parsed.dispatch = "help"
234
+ idx += 1
235
+ continue
236
+
237
+ if flag in BOOLEAN_FLAGS:
238
+ if inline_value is not None:
239
+ parsed.parse_error = f"选项 {flag} 不接受参数值"
240
+ if flag in seen_flags and parsed.parse_error is None:
241
+ parsed.parse_error = f"选项 {flag} 只允许指定一次 ({flag} may be supplied once)"
242
+ seen_flags.add(flag)
243
+ if flag == "--summary":
244
+ parsed.summary = True
245
+ elif flag == "--diagnostics":
246
+ parsed.diagnostics = True
247
+ elif flag == "--dry-run":
248
+ parsed.dry_run = True
249
+ elif flag == "--initial-publish":
250
+ exclusive_actions.append("initial-publish")
251
+ parsed.mode = "initial"
252
+ parsed.action = "initial-publish"
253
+ elif flag == "--initial-commit-only":
254
+ exclusive_actions.append("initial-commit-only")
255
+ parsed.mode = "initial-commit-only"
256
+ parsed.action = "initial-commit-only"
257
+ elif flag == "--initial-branch-publish":
258
+ exclusive_actions.append("initial-branch-publish")
259
+ parsed.mode = "initial_branch"
260
+ parsed.action = "initial-branch-publish"
261
+ elif flag in {"--repo-plan", "--repo-ensure"}:
262
+ exclusive_actions.append(flag.lstrip("-"))
263
+ elif flag == "--ci-required":
264
+ parsed.ci_required = True
265
+ elif flag == "--agent-trace":
266
+ parsed.agent_trace = True
267
+ idx += 1
268
+ continue
269
+
270
+ if flag in VALUE_FLAGS:
271
+ canon_flag = "--message" if flag == "-m" else flag
272
+ if canon_flag not in repeatable_flags:
273
+ if canon_flag in seen_flags and parsed.parse_error is None:
274
+ parsed.parse_error = f"选项 {flag} 只允许指定一次 ({flag} may be supplied once)"
275
+ seen_flags.add(canon_flag)
276
+ if inline_value is not None:
277
+ value = inline_value
278
+ step = 1
279
+ else:
280
+ if idx + 1 >= total:
281
+ parsed.parse_error = f"选项 {flag} 缺少参数值"
282
+ break
283
+ value = argv[idx + 1]
284
+ step = 2
285
+
286
+ if flag == "--mode":
287
+ explicit_mode_flag = True
288
+ parsed.mode = value
289
+ parsed.action = value
290
+ elif flag == "--repo":
291
+ parsed.repo = value
292
+ elif flag in {"--message", "-m"}:
293
+ parsed.message = value
294
+ elif flag == "--remote":
295
+ parsed.remote = value
296
+ elif flag == "--remote-branch":
297
+ parsed.remote_branch = value
298
+ elif flag == "--source-remote":
299
+ parsed.source_remote = value
300
+ elif flag == "--expected-target-oid":
301
+ parsed.expected_target_oid = value
302
+ elif flag == "--snapshot":
303
+ parsed.snapshot = value
304
+ elif flag == "--allow-test-fixture":
305
+ parsed.allow_test_fixtures.append(value)
306
+ elif flag == "--fixture-exceptions":
307
+ parsed.fixture_exceptions = value
308
+ elif flag == "--allow-large-binary":
309
+ parsed.allow_large_binary = value
310
+ elif flag == "--reviewed-sensitive-source":
311
+ parsed.reviewed_sensitive_source = value
312
+ elif flag == "--merge-parent":
313
+ parsed.merge_parent = value
314
+ elif flag == "--publish-existing-branch":
315
+ exclusive_actions.append("publish-existing-branch")
316
+ parsed.mode = "publish_existing_branch"
317
+ parsed.action = "publish-existing-branch"
318
+ parsed.head_oid = value
319
+ elif flag == "--publish-existing-history":
320
+ exclusive_actions.append("publish-existing-history")
321
+ parsed.mode = "publish_existing_history"
322
+ parsed.action = "publish-existing-history"
323
+ parsed.head_oid = value
324
+ elif flag == "--resume-existing-history-publish":
325
+ exclusive_actions.append("resume-existing-history-publish")
326
+ parsed.mode = "resume"
327
+ parsed.action = "resume-existing-history-publish"
328
+ parsed.head_oid = value
329
+ elif flag == "--resume-publish":
330
+ exclusive_actions.append("resume-publish")
331
+ parsed.mode = "resume"
332
+ parsed.action = "resume-publish"
333
+ parsed.head_oid = value
334
+ elif flag == "--resume-initial-publish":
335
+ exclusive_actions.append("resume-initial-publish")
336
+ parsed.mode = "resume"
337
+ parsed.action = "resume-initial-publish"
338
+ parsed.head_oid = value
339
+ elif flag == "--sync-published-branch":
340
+ exclusive_actions.append("sync-published-branch")
341
+ parsed.mode = "sync_published_branch"
342
+ parsed.action = "sync-published-branch"
343
+ parsed.head_oid = value
344
+ elif flag == "--publish-integration-candidate":
345
+ exclusive_actions.append("publish-integration-candidate")
346
+ elif flag == "--retire-remote-branch":
347
+ exclusive_actions.append("retire-remote-branch")
348
+ parsed.mode = "retire_remote_branch"
349
+ parsed.action = "retire-remote-branch"
350
+ parsed.retire_branch = value
351
+ elif flag == "--retire-local-branch":
352
+ exclusive_actions.append("retire-local-branch")
353
+ parsed.mode = "retire_local_branch"
354
+ parsed.action = "retire-local-branch"
355
+ parsed.retire_branch = value
356
+ elif flag == "--expected-remote-oid":
357
+ parsed.expected_remote_oid = value
358
+ elif flag == "--expected-local-oid":
359
+ parsed.expected_local_oid = value
360
+ elif flag == "--expected-integrated-oid":
361
+ parsed.expected_integrated_oid = value
362
+ elif flag == "--integrated-into":
363
+ parsed.integrated_into = value
364
+ elif flag == "--retirement-plan-id":
365
+ parsed.retirement_plan_id = value
366
+ elif flag == "--ci-status":
367
+ parsed.ci_status = value
368
+ elif flag == "--ci-commit-oid":
369
+ parsed.ci_commit_oid = value
370
+ elif flag == "--ci-verification-source":
371
+ parsed.ci_verification_source = value
372
+ parsed.ci_verification_source_seen = True
373
+ elif flag == "--ci-verified-at":
374
+ parsed.ci_verified_at = value
375
+ elif flag == "--repository-id":
376
+ parsed.repository_id = value
377
+ elif flag == "--allocation-id":
378
+ parsed.allocation_id = value
379
+ elif flag == "--task-key":
380
+ parsed.task_key = value
381
+ elif flag == "--authority-key":
382
+ parsed.authority_key = value
383
+ elif flag == "--worktree-path":
384
+ parsed.worktree_path = value
385
+ elif flag == "--role":
386
+ parsed.role = value
387
+ elif flag == "--trailer-agent":
388
+ parsed.trailer_agent = value
389
+ elif flag == "--trace-ref":
390
+ parsed.trace_ref = value
391
+ elif flag == "--scanner":
392
+ for item in value.split(","):
393
+ cleaned = item.strip()
394
+ if cleaned:
395
+ parsed.scanners.append(cleaned)
396
+ elif flag == "--sarif-cmd":
397
+ parsed.sarif_cmd = value
398
+ elif flag == "--opa-policy":
399
+ parsed.opa_policy = value
400
+ elif flag == "--opa-query":
401
+ parsed.opa_query = value
402
+ idx += step
403
+ continue
404
+
405
+ if token.startswith("-"):
406
+ parsed.unknown_flags.append(token)
407
+ if parsed.parse_error is None:
408
+ parsed.parse_error = f"不支持的选项: {token}"
409
+ else:
410
+ parsed.unknown_flags.append(token)
411
+ if parsed.parse_error is None:
412
+ parsed.parse_error = f"位置参数必须放在 `--` 之后: {token}"
413
+ idx += 1
414
+
415
+ if parsed.dispatch in {"version", "help"}:
416
+ if parsed.summary:
417
+ parsed.dispatch = "core"
418
+ parsed.parse_error = "--version/--help 不能与 --summary 混用"
419
+ return parsed
420
+
421
+ if parsed.diagnostics and not parsed.summary and parsed.parse_error is None:
422
+ parsed.parse_error = "--diagnostics requires --summary"
423
+ return parsed
424
+
425
+ if "repo-plan" in exclusive_actions or "repo-ensure" in exclusive_actions:
426
+ if len(exclusive_actions) > 1 or explicit_mode_flag:
427
+ parsed.parse_error = "--repo-plan/--repo-ensure 不能与其他动作选项混用"
428
+ else:
429
+ parsed.dispatch = "bootstrap"
430
+ return parsed
431
+
432
+ if "publish-integration-candidate" in exclusive_actions:
433
+ if len(exclusive_actions) > 1 or explicit_mode_flag:
434
+ parsed.parse_error = "--publish-integration-candidate 不能与其他动作选项混用"
435
+ else:
436
+ parsed.dispatch = "integration_publish"
437
+ return parsed
438
+
439
+ if parsed.parse_error:
440
+ return parsed
441
+
442
+ if len(exclusive_actions) > 1:
443
+ if "resume-initial-publish" in exclusive_actions and "initial-publish" in exclusive_actions:
444
+ parsed.parse_error = "--resume-initial-publish 不接受 --initial-publish"
445
+ else:
446
+ parsed.parse_error = "互斥模式选项不能同时指定"
447
+ return parsed
448
+
449
+ if exclusive_actions and explicit_mode_flag:
450
+ parsed.parse_error = "--mode 不能与互斥模式选项同时指定"
451
+ return parsed
452
+
453
+ if parsed.action not in {
454
+ "normal",
455
+ "verify-only",
456
+ "commit-only",
457
+ "initial-publish",
458
+ "initial-commit-only",
459
+ "initial-branch-publish",
460
+ "publish-existing-branch",
461
+ "publish-existing-history",
462
+ "resume-publish",
463
+ "resume-initial-publish",
464
+ "resume-existing-history-publish",
465
+ "sync-published-branch",
466
+ "retire-remote-branch",
467
+ "retire-local-branch",
468
+ }:
469
+ parsed.parse_error = f"--mode 仅支持 commit-only 或 verify-only: {parsed.mode}"
470
+ return parsed
471
+
472
+ if parsed.action == "initial-publish" and not parsed.remote:
473
+ parsed.parse_error = "--initial-publish 必须指定 --remote"
474
+ return parsed
475
+
476
+ if parsed.action in {"initial-branch-publish", "publish-existing-branch", "publish-existing-history", "resume-initial-publish", "resume-existing-history-publish", "sync-published-branch", "retire-remote-branch", "retire-local-branch"} and not parsed.remote:
477
+ parsed.parse_error = f"--{parsed.action} 必须指定 --remote"
478
+ return parsed
479
+
480
+ if parsed.action in {"normal", "commit-only", "verify-only", "initial-commit-only"} and parsed.remote is not None:
481
+ parsed.parse_error = "--remote 只允许与 --initial-publish 或 --initial-branch-publish 一起使用"
482
+ return parsed
483
+
484
+ if parsed.action == "resume-publish":
485
+ if parsed.remote is not None:
486
+ parsed.parse_error = "--resume-publish 不接受 --remote"
487
+ return parsed
488
+ if parsed.message is not None:
489
+ parsed.parse_error = "--resume-publish 不接受 --message"
490
+ return parsed
491
+ if parsed.reviewed_sensitive_source is not None:
492
+ if not parsed.paths:
493
+ parsed.parse_error = "reviewed resume publication 要求 exact review scope 文件列表"
494
+ return parsed
495
+ elif parsed.paths:
496
+ parsed.parse_error = "--resume-publish 不接受文件列表"
497
+ return parsed
498
+ if parsed.dry_run:
499
+ parsed.parse_error = "--resume-publish 不支持 --dry-run"
500
+ return parsed
501
+
502
+ if parsed.action == "resume-initial-publish":
503
+ if parsed.message is not None:
504
+ parsed.parse_error = "--resume-initial-publish 不接受 --message"
505
+ return parsed
506
+ if parsed.paths:
507
+ parsed.parse_error = "--resume-initial-publish 不接受文件列表"
508
+ return parsed
509
+ if parsed.dry_run:
510
+ parsed.parse_error = "--resume-initial-publish 不支持 --dry-run"
511
+ return parsed
512
+ if len(parsed.allow_test_fixtures) != len(set(parsed.allow_test_fixtures)):
513
+ parsed.parse_error = "duplicate root resume test fixture path"
514
+ return parsed
515
+
516
+ if parsed.action in {"retire-remote-branch", "retire-local-branch"} and parsed.ci_required and parsed.ci_status in (None, "", "NOT_REQUIRED"):
517
+ parsed.parse_error = "--ci-required 必须指定 --ci-status"
518
+ return parsed
519
+
520
+ if parsed.snapshot is not None:
521
+ if parsed.action != "initial-publish":
522
+ parsed.parse_error = "--snapshot 只允许与 --initial-publish 一起使用"
523
+ return parsed
524
+ if len(parsed.snapshot) != 64 or not all(ch in "0123456789abcdef" for ch in parsed.snapshot):
525
+ parsed.parse_error = "--snapshot 要求 64 位小写十六进制 ID"
526
+ return parsed
527
+
528
+ if parsed.action == "sync-published-branch" and (
529
+ parsed.message is not None
530
+ or parsed.allow_test_fixtures
531
+ or parsed.paths
532
+ or parsed.merge_parent
533
+ or parsed.snapshot
534
+ or parsed.reviewed_sensitive_source
535
+ ):
536
+ parsed.parse_error = "--sync-published-branch 不接受提交内容、fixture override 或路径参数"
537
+ return parsed
538
+
539
+ if parsed.action in {"retire-remote-branch", "retire-local-branch"} and (
540
+ parsed.message is not None
541
+ or parsed.allow_test_fixtures
542
+ or parsed.fixture_exceptions
543
+ or parsed.allow_large_binary
544
+ or parsed.reviewed_sensitive_source
545
+ or parsed.merge_parent
546
+ or parsed.paths
547
+ or parsed.snapshot
548
+ ):
549
+ parsed.parse_error = f"--{parsed.action} 不接受提交内容、exception、review 或路径参数"
550
+ return parsed
551
+
552
+ return parsed