Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

publish/sync fail with COMMIT_FAILED when the friction log is in a git-ignored directory

未关闭 适合新手
#87 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wevm/frog 的其他 Issue

查看 wevm/frog 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。