Skip to content

feat(drupal-core): switch cache seed to bare repo, fetch via remote#154

Merged
rfay merged 2 commits into
mainfrom
20260511_rfay_bare_cache_seed
May 12, 2026
Merged

feat(drupal-core): switch cache seed to bare repo, fetch via remote#154
rfay merged 2 commits into
mainfrom
20260511_rfay_bare_cache_seed

Conversation

@rfay
Copy link
Copy Markdown
Member

@rfay rfay commented May 11, 2026

Summary

  • Replaces the git clone --reference approach with a fetch-based workflow using a bare git repo as the cache seed
  • On workspace start, if the cache is a bare repo: git init + fetch from bare cache (fast, local) + git remote remove drupalcache + fetch delta from origin + fetch issue fork if applicable + checkout
  • Removes the ambiguous-ref and dirty-working-tree problems that --reference caused (Inappropriate changed files shown in git status on Drupal core checkout #151)
  • Updates update-drupal-cache script to use git clone --bare for initial setup and adds migration instructions
  • Updates docs/admin/server-setup.md with bare-repo setup and migration steps

Why the old approach was broken: git clone --reference borrows objects from a local reference repo via info/alternates. When the cache was a non-bare working-tree clone, files could have pre-existing timestamps and states that survived into the workspace, causing dirty git trees. The bare approach gives every workspace a clean object store with no working-tree state from the cache.

Backward compat: Non-bare cache seeds still work (legacy path preserved). No-cache path is unchanged.

Test plan

  • CI passes (exercises no-cache path, unchanged)
  • Create workspace with issue fork on server with bare cache — confirm clean git tree
  • Verify update-drupal-cache runs correctly on both coder.ddev.com and staging-coder.ddev.com

🤖 Generated with Claude Code

rfay and others added 2 commits May 11, 2026 17:30
The previous --reference clone approach used a non-bare cache with a
working tree. When the working tree drifted from the fetched objects,
git clone could populate the workspace with files at old timestamps that
git reset --hard HEAD failed to clean up reliably.

Replace with a fetch-based approach:
- git init + git remote add drupalcache (bare)
- git fetch drupalcache  (fast local copy of all objects, no working tree)
- git remote remove drupalcache
- git fetch origin       (delta only — new commits since cache was last refreshed)
- git fetch issue        (issue fork delta, if applicable)
- git checkout -b main --track origin/main

This guarantees a fresh working tree every time and eliminates the
pre-existing-file problem entirely. Non-bare caches (legacy) still work
via the --reference fallback path.

update-drupal-cache now detects bare repos and skips the unnecessary
git merge --ff-only step (bare repos have no working tree to update).
Non-bare repos still get the merge for backward compatibility.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pass the bare seed path on staging-coder.ddev.com as cache_path so
CI workspaces exercise the bare-remote fetch path in template.tf.
Previously tests used /tmp/ci-no-cache (nonexistent) and fell through
to the no-cache branch, never testing the cache code path.

Also adds a "git tree is clean" assertion to the issue-fork job to
catch dirty-checkout regressions (the original bug in #151).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rfay rfay force-pushed the 20260511_rfay_bare_cache_seed branch from 15e9e3f to 5cf6777 Compare May 11, 2026 23:43
@rfay rfay merged commit 6166c93 into main May 12, 2026
21 checks passed
@rfay rfay deleted the 20260511_rfay_bare_cache_seed branch May 12, 2026 00:01
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.

1 participant