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 8cd38f3 commit 727ae1aCopy full SHA for 727ae1a
app/models/examples/app_file.rb
@@ -39,7 +39,7 @@ def readlines
39
end
40
41
def read
42
- return git_read if @revision == "HEAD" # Don’t cache HEAD
+ return disk_read if @revision == "HEAD" # Don’t cache HEAD
43
44
Rails.cache.fetch([:app_file, @revision, @path]) { git_read }
45
@@ -78,10 +78,17 @@ def source(lines: nil)
78
79
private
80
81
+ def disk_read
82
+ git_read.presence || file_read
83
+ end
84
+
85
+ def file_read
86
+ File.read(@path)
87
88
89
def git_read
- Dir.chdir(ENV.fetch("REPOSITORY_ROOT", ".")) do
- `git show #{@revision}:#{@path}`
- end
90
+ git_dir = ENV.fetch("REPOSITORY_ROOT", ".")
91
+ `(cd #{git_dir} && git show #{@revision}:#{@path}) 2>/dev/null`
92
93
94
0 commit comments