Skip to content

[Governance] 普通 commit 后不应让 pack-refs 触发主干保护误报 #137

Description

@liuli195

This was generated by AI during triage.

详细背景

PR #135 中每次正常执行 git commit 都成功创建提交并记录 commit intent,但 post-commit 阶段随后触发 pack-refs,reference-transaction hook 打印:

error: local branch ref update blocked: main
fatal: in 'prepared' phase, update aborted by the reference-transaction hook
error: task 'pack-refs' failed

这发生在普通追加 commit 后,不是 amend / rebase / reset,也不是本地合 main。虽然提交最终成功,但输出看起来像 Git 操作失败,容易让 agent 或用户误判当前提交状态,需要额外 git status / git log 确认。

产品解决方案

普通追加 commit 应输出清晰、无误报的成功路径。主干保护仍必须阻断真实 main/master 非授权更新,但不应把 Git 维护性 pack-refs 行为表现成普通 commit 的错误。

用户视角:正常 commit 后只应看到提交成功和验证结果;如果 hook 拦截的是非阻断维护动作,应降级为静默允许或明确非阻断说明。

详细技术实现方案

  • 复现普通追加 commit 后的 post-commit pack-refs reference-transaction 输入,确认 old/new/ref 组合和 Git 调用路径。
  • 在 branch protection reference-transaction 逻辑中区分真实 ref update 与 pack-refs 维护性引用准备阶段。
  • 保留 main/master 真实更新阻断规则:本地 merge/reset/delete/force rewrite 仍阻断,受控 fast-forward 仍只走 wrapper。
  • 为普通 feature branch append commit + post-commit pack-refs 增加回归测试:commit 成功且 stderr 不出现 main ref update blocked。
  • 为 main/master 非授权更新保留回归测试,确保修复不削弱主干保护。
  • 如果无法可靠区分 pack-refs,则至少让 post-commit 调用路径避免触发 pack-refs,或把该维护失败转为非阻断诊断并说明 commit 已成功。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:P1High priority: important correctness or workflow reliability improvementready-for-agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions