Uh oh!
There was an error while loading. Please reload this page.
Add filecache to git plugin FileContent with configurable TTL - #2798
Conversation
The git plugin's FileContent method was cloning the repo on every call. This adds caching using filecache (matching the github plugin pattern), with TTL controlled by DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL env var. Includes tests for cache hit, TTL expiry, and invalid TTL handling.
There was a problem hiding this comment.
Pull request overview
Adds file-based caching for gitPlugin.FileContent so git+https plugin repos aren’t cloned on every read, with cache TTL controlled by DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL.
Changes:
- Add a
filecache-backed cache for git pluginFileContent, with TTL read fromDEVBOX_X_GITHUB_PLUGIN_CACHE_TTL. - Add tests covering cache hit behavior, TTL expiry behavior, and invalid TTL parsing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| internal/plugin/git.go | Introduces filecache for FileContent and reads TTL from env var. |
| internal/plugin/git_test.go | Adds integration-style tests using a local bare git repo to validate cache/TTL behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: John Lago <750845+Lagoja@users.noreply.github.com>
Use ttl.String() instead of raw env var in cache keys to avoid path-separator injection and trailing slashes. Add t.Skip guard in setupLocalGitRepo for CI environments without git. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Summary
When we implemented the new git+https plugins feature in the last release, we did not configure it to use the DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL env var to set TTL for the plugin. The git plugin's FileContent method was cloning the plugin repo on every call. This adds caching using filecache (matching the github plugin pattern), with TTL controlled by DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL env var.
How was it tested?
Added 3 tests:
Cache hit (TestGitPluginFileContentCache) — Clones from a local bare repo, then deletes the repo on disk and calls FileContent again. The second call succeeds, proving it’s served from cache rather than attempting a fresh clone.
TTL expiry via env var (TestGitPluginFileContentCacheRespectsEnvVar) — Sets DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL=1ns so entries expire immediately, clones once, deletes the repo, then calls FileContent again. The second call fails because the expired cache entry forces a re-clone against the now-deleted repo. This proves the env var controls cache lifetime.
Invalid TTL (TestGitPluginFileContentCacheInvalidTTL) — Sets the env var to "not-a-duration" and verifies FileContent returns a parse error before attempting any clone.
Will also test functionality via a dev release.
Is this backwards compatible?
Yes