Documentation
¶
Index ¶
- func CopyTree(src, dst string) error
- func EnsureWorktreeDeps(mainRepoPath, worktreePath, worktreeDomain string, secured bool)
- func InstallDependencies(projectPath string) error
- func IsMainRepo(sitePath string) bool
- func MainBranch(sitePath string) string
- func SanitizeBranch(branch string) string
- type Worktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyTree ¶ added in v1.16.0
CopyTree copies src to dst recursively. It first tries a reflink-aware fast path via cp, which is near-instant on btrfs, XFS with reflink=1, and APFS. Falls back to a plain recursive Go copy elsewhere. dst must not already exist.
func EnsureWorktreeDeps ¶
EnsureWorktreeDeps sets up a worktree checkout with the dependencies it needs:
- vendor/ and node_modules/ are seeded from the main repo via a reflink copy (near-instant on btrfs, xfs-reflink, APFS; plain copy on ext4), then reconciled against the worktree's own lockfiles via composer install / npm ci.
- .env is copied from the main repo with APP_URL rewritten to http(s)://<worktreeDomain>
Copying (rather than symlinking) is required because PHP resolves __DIR__ through symlinks, which would make Composer's ClassLoader initialise against the main repo directory and silently load stale classes from there.
func InstallDependencies ¶ added in v1.16.0
InstallDependencies runs composer install and the JS package manager matching whatever lockfile the project ships so vendor/ and node_modules/ match that checkout's own lockfiles. composer goes through the lerd shim (which routes into the project's PHP-FPM container); JS tooling goes through whichever of pnpm/yarn/bun/npm is on PATH, preferring the npm shim from BinDir when the project uses npm so the fnm Node version is picked up.
Each install is skipped when the relevant install marker (vendor/composer/installed.json for composer, the package manager's own marker under node_modules for JS) is at-or-newer than the lockfile — nothing has drifted, so re-running install would just burn cycles on post-autoload-dump scripts (Laravel package:discover, Filament asset publish, etc.) for no observable change.
Errors are aggregated and returned; callers should log them rather than treat them as fatal since the worktree is still usable with the copied trees from main.
func IsMainRepo ¶
IsMainRepo returns true if sitePath/.git is a directory (not a file). A file means the repo itself is a worktree, not the main checkout.
func MainBranch ¶
MainBranch returns the current branch of the main repo checkout at sitePath, or an empty string if it cannot be determined.
func SanitizeBranch ¶
SanitizeBranch converts a branch name to a subdomain-safe slug.
Types ¶
type Worktree ¶
type Worktree struct {
Name string // subdirectory name under .git/worktrees/
Branch string // sanitized branch (subdomain-safe)
Path string // absolute path to checkout dir
Domain string // "<sanitized-branch>.<siteDomain>"
}
Worktree represents a git worktree checkout for a registered site.
func DetectWorktrees ¶
DetectWorktrees returns the list of active worktrees for the given site.