chore(scripts): Add git worktree management tools#5497
chore(scripts): Add git worktree management tools#5497ericapisani wants to merge 1 commit intomasterfrom
Conversation
Add helper scripts and make targets to simplify creating and managing git worktrees. The worktree-create script automates branch creation and virtual environment setup (preferring uv if available). The worktree-delete script removes worktrees and offers to clean up associated branches. Worktrees are particularly useful when working on multiple features independently of each other without needing to switch branches. This also enables parallelizing Claude Code sessions if desired, reducing friction when managing multiple development contexts. Co-Authored-By: Claude <noreply@anthropic.com>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
| WORKTREE_DIR="$REPO_ROOT/.worktrees/$WORKTREE_NAME" |
There was a problem hiding this comment.
Path traversal allows worktree creation outside intended directory
The Makefile regex validation ^[a-zA-Z0-9_/-]+The Makefile regex validation permits forward slashes in the NAME parameter. This allows path traversal sequences like ../../footo create worktrees outside the intended.worktrees` directory. An attacker with access to the Makefile target could create worktrees in arbitrary locations within the filesystem (relative to repo root), potentially overwriting or polluting other directories.
Suggested fix: Add validation in the script to reject names containing path traversal patterns, or modify the Makefile regex to disallow forward slashes.
| WORKTREE_DIR="$REPO_ROOT/.worktrees/$WORKTREE_NAME" | |
| if [[ "$WORKTREE_NAME" == *..* ]]; then | |
| echo "Error: worktree name cannot contain '..'" >&2 | |
| exit 1 | |
| fi |
Also found at 1 additional location
scripts/worktree-delete.sh:13-13
Identified by Warden [find-bugs] · QA3-AZZ
Codecov Results 📊✅ 13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 6.31s All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 13701 uncovered lines. Files with missing lines (180)
Generated by Codecov Action |
Add helper scripts and make targets to simplify creating and managing git worktrees. The worktree-create script automates branch creation and virtual environment setup (preferring uv if available). The worktree-delete script removes worktrees and offers to clean up associated branches.
Worktrees are particularly useful when working on multiple features independently of each other without needing to switch branches. This also enables parallelizing Claude Code sessions if desired, reducing friction when managing multiple development contexts.