-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(dev): autoprovision devenv when making a new git worktree #109889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,7 @@ if [ "$(uname -s)" == "Darwin" ] && [ ! -f "/Library/Developer/CommandLineTools/ | |
| return 1 | ||
| fi | ||
|
|
||
| SENTRY_ROOT="$( | ||
| cd "$(dirname "${BASH_SOURCE[0]}")" | ||
| pwd -P | ||
| )" | ||
|
|
||
| source "${SENTRY_ROOT}/scripts/lib.sh" | ||
| source "scripts/lib.sh" | ||
|
|
||
| bold="$(tput bold)" | ||
| red="$(tput setaf 1)" | ||
|
|
@@ -106,9 +101,9 @@ export SENTRY_UI_HOT_RELOAD=1 | |
|
|
||
| ### You can override the exported variables with a .env file | ||
| # All exports should happen before here unless they're safeguarded (see devenv error reporting below) | ||
| if [ -f "${SENTRY_ROOT}/.env" ]; then | ||
| info "Loading variables from ${SENTRY_ROOT}/.env" | ||
| dotenv "${SENTRY_ROOT}/.env" | ||
| if [ -f ".env" ]; then | ||
| info "Loading variables from .env" | ||
| dotenv | ||
| fi | ||
|
|
||
| ## Notify of reporting to Sentry | ||
|
|
@@ -133,8 +128,11 @@ PATH_add "/opt/homebrew/bin" | |
|
|
||
| ### Python ### | ||
|
|
||
| if [ -f .venv/bin/devenv ]; then | ||
| DEVENV=.venv/bin/devenv | ||
| export VIRTUAL_ENV="${PWD}/.venv" | ||
| PATH_add "${VIRTUAL_ENV}/bin" | ||
|
|
||
| if [ -f "${VIRTUAL_ENV}/bin/devenv" ]; then | ||
| DEVENV="${VIRTUAL_ENV}/bin/devenv" | ||
| else | ||
| DEVENV=devenv | ||
| fi | ||
|
|
@@ -148,9 +146,6 @@ https://github.com/getsentry/devenv#install | |
| ' | ||
| fi | ||
|
|
||
| PATH_add .venv/bin | ||
| export VIRTUAL_ENV="$PWD/.venv" | ||
|
|
||
| if ! require sentry; then | ||
| warn "Your virtualenv is activated, but sentry doesn't seem to be installed." | ||
| commands_to_run+=("devenv sync") | ||
|
|
@@ -169,25 +164,23 @@ if ! require pre-commit; then | |
| fi | ||
|
|
||
| ### dotagents ### | ||
| if [ -f "${SENTRY_ROOT}/agents.toml" ] && [ ! -d "${SENTRY_ROOT}/.agents/skills/commit" ]; then | ||
|
|
||
| if [ -f "agents.toml" ] && [ ! -d ".agents/skills/commit" ]; then | ||
| warn "Agent skills not installed." | ||
| commands_to_run+=("devenv sync") | ||
| fi | ||
|
|
||
| python3 -m tools.docker_memory_check | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i took the liberty of removing this; unused for a long time now |
||
|
|
||
| ### Node ### | ||
|
|
||
| # not needed for getsentry | ||
| if [ "${PWD##*/}" = "sentry" ]; then | ||
| if [ -f ".node-version" ]; then | ||
| debug "Checking node..." | ||
|
|
||
| if [ "${SENTRY_DEVENV_SKIP_FRONTEND:-}" != "1" ]; then | ||
| if ! require node; then | ||
| die "You don't seem to have node installed. Please run devenv sync." | ||
| fi | ||
|
|
||
| read -r node_version < .node-version | ||
| read -r node_version < ".node-version" | ||
| if [ "v${node_version}" != "$(node --version)" ]; then | ||
| die "Unexpected $(command -v node) version. Please run devenv sync." | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,11 +168,9 @@ CI=true pnpm test <file_path> | |
| CI=true pnpm test components/avatar.spec.tsx | ||
| ``` | ||
|
|
||
| > For detailed development patterns, see nested AGENTS.md files: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these deleted instructions are already mentioned below |
||
| > | ||
| > - **Backend patterns**: `src/AGENTS.md` | ||
| > - **Backend testing patterns**: `tests/AGENTS.md` | ||
| > - **Frontend patterns**: `static/AGENTS.md` | ||
| ### Git worktrees | ||
|
|
||
| Each worktree has its own `.venv`. When you create a new worktree with `git worktree add`, a post-checkout hook runs `devenv sync` in the new worktree to setup the dev environment. Otherwise run `devenv sync` once in the new worktree, then `direnv allow` to validate and activate the dev environment. | ||
|
|
||
| ### Context-Aware Loading | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/usr/bin/env bash | ||
| # When a new worktree is created (git worktree add), run devenv sync to create | ||
| # a virtualenv in the new worktree. Git calls this hook with three arguments: | ||
| # $1 = previous HEAD ref, $2 = new HEAD ref, $3 = 1 (branch) or 0 (file checkout). | ||
| # For a new worktree there is no "previous" commit, so Git passes 40 zeros as $1. | ||
| # We only run our logic when $1 is all zeros (new worktree or initial clone). | ||
| # Git invokes this hook automatically after checkout (e.g. git clone, checkout, switch, worktree add); | ||
| # the hook runs with the worktree root as the current directory. | ||
| set -eu | ||
|
|
||
| # Only act when $1 is all zeros (no previous HEAD): that happens for worktree add | ||
| # and for clone. We only want to run for worktree add; after clone, CI or the | ||
| # user runs devenv sync explicitly. In a clone .git is a dir; in a worktree .git | ||
| # is a file. So skip unless we're in a worktree to avoid affecting clone/CI. | ||
| if [ "$1" != "0000000000000000000000000000000000000000" ]; then | ||
| exit 0 | ||
| fi | ||
| WORKTREE_ROOT="${GIT_WORK_TREE:-$PWD}" | ||
| # .git is a file in an added worktree, a directory in the main clone; skip if main clone | ||
| if [ ! -f "$WORKTREE_ROOT/.git" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Only run in worktrees that have our devenv setup (sync.py); skip when .venv already exists | ||
| if [ ! -d "$WORKTREE_ROOT/.venv" ] && [ -f "$WORKTREE_ROOT/devenv/sync.py" ]; then | ||
| if command -v devenv >/dev/null 2>&1; then | ||
| echo "New worktree detected. Running devenv sync to create virtualenv..." | ||
| if ! (cd "$WORKTREE_ROOT" && devenv sync); then | ||
| echo "Warning: devenv sync failed. Run 'cd $WORKTREE_ROOT && devenv sync' manually." | ||
| fi | ||
| else | ||
| echo "New worktree detected. Install devenv and run: cd $WORKTREE_ROOT && devenv sync" | ||
| fi | ||
| fi |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need SENTRY_ROOT; this was from the era where we had shared sentry+getsentry venvs