Skip to content

chore(devenv): add worktree bootstrap helper script#274

Draft
armenzg wants to merge 1 commit into
mainfrom
armenzg/dev-env/worktree-hook
Draft

chore(devenv): add worktree bootstrap helper script#274
armenzg wants to merge 1 commit into
mainfrom
armenzg/dev-env/worktree-hook

Conversation

@armenzg
Copy link
Copy Markdown
Member

@armenzg armenzg commented May 27, 2026

Add a dedicated helper script for newly created git worktrees.

Fresh worktrees often run make before a local .venv exists, which leads to ambient interpreter usage. scripts/setup-worktree.sh now bootstraps the worktree by running devenv sync and, when available, allows direnv for the repository.

README now documents this as the first step after creating a new worktree.

Made with Cursor

Add a single-command setup helper for newly created git worktrees so developers
can run devenv sync before invoking Makefile targets.

Co-Authored-By: Codex <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Script enables direnv that warns against its own use case
    • Modified setup-worktree.sh to skip 'direnv allow' when the directory basename doesn't match the expected repo name, preventing confusing warnings in worktrees.

Create PR

Or push these changes by commenting:

@cursor push 03705e07ff
Preview (03705e07ff)
diff --git a/scripts/setup-worktree.sh b/scripts/setup-worktree.sh
--- a/scripts/setup-worktree.sh
+++ b/scripts/setup-worktree.sh
@@ -15,7 +15,10 @@
 devenv sync
 
 if command -v direnv >/dev/null 2>&1 && [ -f .envrc ]; then
-  direnv allow "${repo_root}" >/dev/null 2>&1 || true
+  expected_repo_name="$(awk -F'[][.]' '/^\[venv\./{print $3; exit}' devenv/config.ini 2>/dev/null)"
+  if [ -z "$expected_repo_name" ] || [ "$(basename "${repo_root}")" = "$expected_repo_name" ]; then
+    direnv allow "${repo_root}" >/dev/null 2>&1 || true
+  fi
 fi
 
 echo "Worktree setup complete."

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 1a80630. Configure here.

Comment thread scripts/setup-worktree.sh
devenv sync

if command -v direnv >/dev/null 2>&1 && [ -f .envrc ]; then
direnv allow "${repo_root}" >/dev/null 2>&1 || true
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Script enables direnv that warns against its own use case

Low Severity

The direnv allow on line 18 enables .envrc, which contains a basename guard that prints warnings and skips devenv sync when the directory name doesn't match the expected sentry-protos from devenv/config.ini. Since worktrees typically have different directory names, the script's target audience will see confusing messages like "Move this checkout to a path ending in '/sentry-protos'" on every shell prompt after running this helper — undermining the seamless bootstrap experience the script is meant to provide.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a80630. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant