MCPcopy Index your code
hub / github.com/jetify-com/devbox / FileContent

Method FileContent

internal/plugin/git.go:192–210  ·  view source on GitHub ↗
(subpath string)

Source from the content-addressed store, hash-verified

190}
191
192func (p *gitPlugin) FileContent(subpath string) ([]byte, error) {
193 ttl := 24 * time.Hour
194 var err error
195 ttlStr := os.Getenv("DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL")
196 if ttlStr != "" {
197 ttl, err = time.ParseDuration(ttlStr)
198 if err != nil {
199 return nil, fmt.Errorf("invalid DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL=%q: %w", ttlStr, err)
200 }
201 }
202 cacheKey := p.LockfileKey() + "/" + subpath + "/" + ttl.String()
203 return gitCache.GetOrSet(cacheKey, func() ([]byte, time.Duration, error) {
204 content, err := p.cloneAndRead(subpath)
205 if err != nil {
206 return nil, 0, err
207 }
208 return content, ttl, nil
209 })
210}
211
212func (p *gitPlugin) LockfileKey() string {
213 return p.ref.String()

Calls 3

LockfileKeyMethod · 0.95
cloneAndReadMethod · 0.95
StringMethod · 0.45