Skip to content

fix(openemr-cmd): bind primary .git into worktree containers#696

Open
bradymiller wants to merge 2 commits intoopenemr:masterfrom
bradymiller:fix-for-worktree-openemrcmd
Open

fix(openemr-cmd): bind primary .git into worktree containers#696
bradymiller wants to merge 2 commits intoopenemr:masterfrom
bradymiller:fix-for-worktree-openemrcmd

Conversation

@bradymiller
Copy link
Copy Markdown
Member

Summary

  • In a linked worktree, .git is a text pointer to an absolute host path inside the primary repo's .git/worktrees/<slug>. That path does not exist inside the worktree's container, so anything that shells out to git fails — npm husky postinstall, lint-staged, prek, composer scripts that read commit metadata.
  • Bind-mount the primary repo's .git/ at the same absolute host path inside the worktree's openemr container so the existing pointer resolves transparently. RW because git writes refs, indexes, packed objects, and the worktree-specific state under .git/worktrees/<slug>/.
  • Restructure the auto-generated override so the openemr service block is always present (previously only emitted for easy-redis), with the redis-only php.ini volume appended into that same block to avoid duplicate YAML keys. Bumps openemr-cmd VERSION to 1.0.30.

After this change, existing worktrees pick up the new mount via openemr-cmd worktree regen <branch> followed by container recreation (worktree down --keep-volumes <branch> + worktree up <branch>).

Test plan

  • Generated easy override: single openemr service block with the .git mount; mysql and couchdb blocks unchanged
  • Generated easy-redis override: single openemr block contains both .git and php.ini volumes (no duplicate keys); redis-master / replicas / sentinels emit unchanged
  • Generated easy-light override: openemr block has only .git; no couchdb / redis blocks
  • All three parse as valid YAML (python3 -c "import yaml; yaml.safe_load(...)")
  • openemr-cmd worktree regen <branch> rewrites an existing worktree's override correctly
  • After regen + recreate, openemr-cmd worktree exec <branch> shell then git status inside the container resolves the repo
  • npm install postinstall hooks (husky) succeed inside a worktree container
  • Existing symlink / path-traversal guards still fire for the prior mounts (lib_root, env_root, php.ini)

🤖 Generated with Claude Code

In a linked worktree, .git is a text pointer to an absolute host path
inside the primary repo's .git/worktrees/<slug>; that path does not
exist inside the worktree's container, so any tool that shells out to
git fails (npm husky, lint-staged, prek, composer scripts that read
commit metadata).

Bind-mount the primary repo's .git directory at the same absolute path
inside the worktree's openemr container so the existing pointer resolves
transparently. Mounted RW because git writes refs, indexes, packed
objects, and the worktree-specific state under .git/worktrees/<slug>/.
Restructure the override emission so the openemr service block is
always present (previously only emitted for easy-redis), with the
redis-only php.ini volume appended into that same block to avoid
duplicate YAML keys.

Bump VERSION to 1.0.30. Existing worktrees pick up the new mount via
'openemr-cmd worktree regen <branch>' followed by container recreation
(worktree down --keep-volumes + worktree up).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 7, 2026 06:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates openemr-cmd’s worktree override generation so linked worktree containers can successfully resolve Git metadata by bind-mounting the primary repo’s .git directory at the same absolute host path inside the container. It also restructures the generated override YAML so the openemr service block is always emitted (and the easy-redis php.ini mount is appended into that same block), and bumps the script version.

Changes:

  • Bind-mount the primary repo’s .git directory into worktree containers to fix Git-dependent tooling inside containers.
  • Restructure generated docker-compose.override.yml output to always include a single openemr service block (avoids duplicate YAML keys for easy-redis).
  • Bump openemr-cmd version to 1.0.30.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utilities/openemr-cmd/openemr-cmd Outdated
fi

# Resolve the primary repo's .git directory. The worktree's own .git is a
# text file containing 'gitdir: <absolute-host-path-to-primary-.git/worktrees/<slug>>'.
git uses the worktree directory's basename (here "openemr-wt-<slug>")
as the per-worktree subdir under <primary>/.git/worktrees/, not the
branch slug alone. The original comment elided the prefix and could
mislead future maintainers.

Comment-only change; no functional impact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants