We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2276798 commit 04b445aCopy full SHA for 04b445a
app/models/examples/app_file.rb
@@ -37,9 +37,9 @@ def readlines
37
end
38
39
def read
40
- Dir.chdir(ENV.fetch("REPOSITORY_ROOT", ".")) do
41
- `git show #{@revision}:#{@path}`
42
- end
+ return git_read if @revision == "HEAD" # Don’t cache HEAD
+
+ Rails.cache.fetch([:app_file, @revision, @path]) { git_read }
43
44
alias_method :content, :read
45
@@ -73,5 +73,13 @@ def source(lines: nil)
73
74
content.strip.html_safe
75
76
77
+ private
78
79
+ def git_read
80
+ Dir.chdir(ENV.fetch("REPOSITORY_ROOT", ".")) do
81
+ `git show #{@revision}:#{@path}`
82
+ end
83
84
85
0 commit comments