git

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyTree added in v1.16.0

func CopyTree(src, dst string) error

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

func EnsureWorktreeDeps(mainRepoPath, worktreePath, worktreeDomain string, secured bool)

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

func InstallDependencies(projectPath string) error

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.

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

func IsMainRepo(sitePath string) bool

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

func MainBranch(sitePath string) string

MainBranch returns the current branch of the main repo checkout at sitePath, or an empty string if it cannot be determined.

func SanitizeBranch

func SanitizeBranch(branch string) string

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

func DetectWorktrees(sitePath, siteDomain string) ([]Worktree, error)

DetectWorktrees returns the list of active worktrees for the given site.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL