worktree: harden the add prefix check and widen the self-test

未关闭
#53 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@nolte 已经在做这个了。

开始于 2026年11月5日。

  • #58 来自 @nolte —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
git, shell
领域
cli, testing

调研方向

Read src/taskfile-include-worktree.yaml and tests/worktree-selftest.sh; the issue lists the module changes and self-test cases. Start by running the self-test and checking how its Taskfile invokes add, including through an includes: wrapper. Done when the prefix checks and messages are hardened, all listed negative cases and wrapper invocation are covered, and the tests work with portable branch setup.

由索引模型根据 Issue 内容生成。

描述

Follow-up from the review of #52 (fix for #50). None of these block #52; they reduce the chance the same class of defect comes back.

Module (src/taskfile-include-worktree.yaml, add)

  • Replace the prefix loop with a single case " $allowed_prefixes " in *" $prefix "*) … esac test, so no loop exit status can leak under set -e in go-task's mvdan/sh.
  • Check [ "$prefix" != "$branch" ] (branch has a /) once, before the prefix test, and give it its own message ("branch lacks a prefix" vs. "prefix not allowed").

Self-test (tests/worktree-selftest.sh)

  • The sed that reads WORKTREE_ALLOWED_PREFIXES only handles a plain literal. When the module is converted to the '{{.NAME | default "…"}}' form CLAUDE.md requires, it exits 2 ("Could not read…"). Read the resolved value instead, or handle both forms.
  • Exercise the module through an includes: wrapper Taskfile (as consumers do) in addition to task -t <module> add.
  • Add negative cases for the slug guard (*/*, *..*), "Destination already exists", and the usage exit code (2).
  • git init -b develop needs git ≥ 2.28; use git init + git symbolic-ref HEAD refs/heads/develop for portability.
主要语言
Shell
星标
0
派生
0
平均合并
11 分钟
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

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

nolte/taskfiles 的其他 Issue

查看 nolte/taskfiles 的全部 Issue

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

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