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

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

@nolte is already working on this.

Since Nov 5, 2026.

  • #58 by @nolte — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, shell
Domain
cli, testing

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Shell
Stars
0
Forks
0
Avg merge
11m
Merged PRs (30d)
2

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nolte/taskfiles

All issues in nolte/taskfiles

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.