mirror of
https://github.com/zed-industries/zed.git
synced 2026-07-30 18:18:07 +00:00
Sometimes when creating Git worktrees, it's necessary to set things up so the new worktree is ready. For example, copying env.vars, installing dependencies, etc. That was already possible in Zed through the tasks system, but you'd only maybe know about that if you read the documentation or is super familiar with it already; nothing in the product in the context of worktrees told you about that. This is what this PR does. Now, in the worktree picker, there's a "" button that opens the `tasks.json` file exposing the `create_worktree` hook, which allows you to plugin all sorts of things to be run by the time of a worktree creation. If you don't already have a `tasks.json` file, we will create a new one for you with a worktree-creation template. Otherwise, we either append the `create_worktree` hook content to it or just open the file. Here's a quick video: https://github.com/user-attachments/assets/21908be4-306b-4cf3-bed0-50d52cad9d79 Release Notes: - Git Worktrees: Improved discoverability of the `create_worktree` hook for setting up things that need to happen by the time of worktree creation.
23 lines
1 KiB
JSON
23 lines
1 KiB
JSON
// Worktree setup tasks, stored in this project's tasks.json.
|
|
// See https://zed.dev/docs/tasks#hooks for the full Tasks Hooks documentation.
|
|
//
|
|
// Tasks with the `create_worktree` hook run automatically right after Zed
|
|
// creates a new git worktree. Use them to get a fresh worktree ready to work
|
|
// in — for example, installing dependencies or copying files that git doesn't
|
|
// track (like `.env`) from the original repository.
|
|
//
|
|
// Two variables are available to these tasks:
|
|
// * $ZED_WORKTREE_ROOT — the root directory of the newly created worktree
|
|
// * $ZED_MAIN_GIT_WORKTREE — the original repository's working directory
|
|
//
|
|
// Uncomment the example below and adjust the command to get started.
|
|
// Note: hooked tasks run as soon as a worktree is created, so only enable
|
|
// commands you want to run automatically.
|
|
[
|
|
// {
|
|
// "label": "Set up new worktree",
|
|
// "command": "cp -n \"$ZED_MAIN_GIT_WORKTREE/.env\" \"$ZED_WORKTREE_ROOT/\" && npm install",
|
|
// "cwd": "$ZED_WORKTREE_ROOT",
|
|
// "hooks": ["create_worktree"]
|
|
// }
|
|
]
|