Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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
Copy link
Member Author

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

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
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand Down
8 changes: 3 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member Author

Choose a reason for hiding this comment

The 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

Expand Down
34 changes: 34 additions & 0 deletions config/hooks/post-checkout
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
7 changes: 6 additions & 1 deletion devenv/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def main(context: dict[str, str]) -> int:

FRONTEND_ONLY = os.environ.get("SENTRY_DEVENV_FRONTEND_ONLY") is not None
SKIP_FRONTEND = os.environ.get("SENTRY_DEVENV_SKIP_FRONTEND") is not None
IN_GIT_WORKTREE = os.path.isfile(f"{reporoot}/.git")

if constants.DARWIN and os.path.exists(f"{constants.root}/bin/colima"):
binroot = f"{reporoot}/.devenv/bin"
Expand Down Expand Up @@ -309,7 +310,11 @@ def main(context: dict[str, str]) -> int:
):
print("⚠️ agent skills failed to install (non-fatal)")

fs.ensure_symlink("../../config/hooks/post-merge", f"{reporoot}/.git/hooks/post-merge")
if not IN_GIT_WORKTREE:
fs.ensure_symlink("../../config/hooks/post-merge", f"{reporoot}/.git/hooks/post-merge")
fs.ensure_symlink(
"../../config/hooks/post-checkout", f"{reporoot}/.git/hooks/post-checkout"
)

sentry_conf = os.environ.get("SENTRY_CONF", f"{constants.home}/.sentry")

Expand Down
106 changes: 0 additions & 106 deletions tests/tools/test_docker_memory_check.py

This file was deleted.

72 changes: 0 additions & 72 deletions tools/docker_memory_check.py

This file was deleted.

Loading