publish/sync fail with COMMIT_FAILED when the friction log is in a git-ignored directory
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- git, typescript
- 领域
- cli
调研方向
故障位于 src/Git.ts 中的 add,它会对可能被 git 忽略的路径执行 git add -- <paths>。拟议的修复新增一个辅助函数,运行 git check-ignore --no-index 并在暂存前过滤掉这些路径;如果没有剩余路径则提前返回。请先阅读 src/Git.ts 中的 add 和 commit,然后在忽略 **/.agents/* 的临时仓库中编写测试。完成标准是:Git.add 成功完成(resolve)且不暂存被忽略的文件,Git.commit 返回 false,未被忽略的路径仍被暂存。
由索引模型根据 Issue 内容生成。
描述
publish and sync stage the entries they touched with git add -- <paths>. When the friction log lives in a git-ignored directory (for example .agents/friction-log/ under a .agents/* ignore rule), git add exits non-zero, and the command returns COMMIT_FAILED after the issues were already filed and the entries marked linked.
Seen with frog 1.1.0.
Proposed fix
Git.add drops paths that git check-ignore --no-index reports before it stages anything, and returns early when nothing is left. --no-index matches how git add walks the working tree: it refuses a path under an excluded directory even when that path is tracked.
diff --git a/src/Git.ts b/src/Git.ts
index e395e6a399e3f38efe537509ac421680bb8da18b..0612d749cf3375ab5f1ea404b15889fbee5aaf1c 100644
--- a/src/Git.ts
+++ b/src/Git.ts
@@ -137,13 +137,39 @@ export async function changedSince(
}
/**
- * Stages paths.
+ * Paths the repository's ignore rules exclude.
+ *
+ * `--no-index` matches how `git add` traverses the working tree: it refuses a path under an
+ * excluded directory even when that path is tracked. The index-aware default disagrees there, so it
+ * would leave the very failure this guards against. The cost is a tracked file matching a
+ * file-level rule, which `git add` would accept and this reports as excluded - a contradictory
+ * configuration, and one worth skipping rather than failing over.
+ *
+ * @param files - Repository-relative paths.
+ * @returns The subset the ignore rules exclude. Empty when git cannot answer.
+ */
+async function ignored(files: readonly string[], options: Options = {}): Promise<Set<string>> {
+ // Exit 1 means nothing matched; any other failure is treated the same way, leaving `add` to
+ // surface the real error.
+ const output = await git(['check-ignore', '--no-index', '--', ...files], options).catch(() => '')
+ return new Set(output ? output.split('\n') : [])
+}
+
+/**
+ * Stages paths, skipping the ones git ignores.
+ *
+ * A friction log kept in an ignored directory is still a complete publish: the entries are filed
+ * and marked linked, and there is nothing left to commit. Staging them would fail the whole command
+ * over paths the repository has deliberately excluded.
*
* @param files - Repository-relative paths. An empty list is a no-op.
*/
export async function add(files: readonly string[], options: Options = {}): Promise<void> {
if (files.length === 0) return
- await git(['add', '--', ...files], options)
+ const excluded = await ignored(files, options)
+ const staged = files.filter((file) => !excluded.has(file))
+ if (staged.length === 0) return
+ await git(['add', '--', ...staged], options)
}
/**
Suggested test
A repo that ignores **/.agents/* with an entry under .agents/friction-log/<id>/friction.md. Git.add resolves without staging, Git.commit returns false, and a path that is not ignored is still staged.
Happy to open a PR with this change and the test if that helps.
- 主要语言
- TypeScript
- 星标
- 267
- 派生
- 11
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
wevm/frog 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
-
frog log rejects Windows repository roots可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
GitHub App token fallback misses recent issues in large repositories可能已有人在做 @blalor 于 57 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 68/100
-
feat: allow local log entries to select an issue form可能已有人在做 @emmajam 于 72 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
melgarafael/DeskcommCRM#3000 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
callstackincubator/simlock#639 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
aws/agentcore-cli#2606 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 7 天内回复
-
ai-driven-qa bug Cosmetic
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复