`trigger deploy`: wrong git metadata and build context from a git worktree
Version: trigger.dev CLI 4.7.7, local deploys (not GitHub Actions or the GitHub App).
config.workspaceDir comes from pkg-types findWorkspaceDir, which looks for the nearest .git/config file. A linked worktree has a .git file, not a directory, so the lookup misses it. Two things then go wrong.
1. A worktree nested inside another checkout (for example repo/.worktrees/release): workspaceDir resolves to the outer checkout.
createGitMetarunsgit logandgit statusthere, so the deployment records the outer checkout's commit, branch, and dirty flag. We saw a deploy built from a clean worktree atae22adffrecorded as23422c6f,main, dirty.- On the native build path,
createContextArchive(config.workspaceDir, …)tars the outer checkout, not the worktree being deployed.
2. A worktree outside any checkout: workspaceDir is the worktree itself, which is correct. But getOriginUrl(join(directory, ".git/config")) reads that path as a file, and in a worktree it doesn't exist. So remoteUrl is always missing. GIT_DIR and GIT_WORK_TREE don't help, because this value never goes through git.
Suggested fix: take both values from git in the project directory: git rev-parse --show-toplevel for the workspace, and git config --get remote.origin.url for the remote. That handles worktrees and respects GIT_DIR. Today we work around the first problem by exporting GIT_DIR and GIT_WORK_TREE and refusing nested-worktree deploys. The second has no workaround short of faking a .git/config.
Independently reproduced both cases against main at 41ad1995b30573a9b55cfaab80c3293b7c35c1f8, using Node 24.18.0 and the locked [email protected].
| Fixture | Observed result |
|---|---|
| Linked worktree inside the main checkout | findWorkspaceDir() selected the outer checkout. Running the current createGitMeta() with that directory returned the outer commit, main, and dirty: true, instead of the clean worktree's commit and branch. |
| Linked worktree outside the main checkout | Workspace resolution was correct, but remoteUrl was missing because .git/config cannot be read through the worktree's .git file. |
Each fixture had its own commit and a committed package-lock.json. As controls, git rev-parse --show-toplevel and git config --get remote.origin.url, run inside each worktree, returned the expected root and origin.
This exercises workspace resolution and the actual metadata helper locally, not a full CLI deployment or native build archive. AI assistance was used for the investigation and tests.
Hi maintainers,
I'm interested in contributing to this issue. I noticed that PR #5105 was automatically closed because of the contributor vouching requirement.
Is this issue still available for contributions, and would you be open to reviewing a fix from a new contributor once approved?
I have experience with TypeScript, Node.js, Git workflows, and backend development, including previous open-source contributions.
I'd be happy to follow the repository's contribution process before starting implementation.
Thanks!