lib/gollum/git_access.rb in gollum-1.3.0 vs lib/gollum/git_access.rb in gollum-1.3.1

- old
+ new

@@ -26,17 +26,21 @@ # Public: Converts a given Git reference to a SHA, using the cache if # available. # # ref - a String Git reference (ex: "master") # - # Returns a String. + # Returns a String, or nil if the ref isn't found. def ref_to_sha(ref) - if sha?(ref) - ref - else - get_cache(:ref, ref) { ref_to_sha!(ref) } - end + ref = ref.to_s + return if ref.empty? + sha = + if sha?(ref) + ref + else + get_cache(:ref, ref) { ref_to_sha!(ref) } + end.to_s + sha.empty? ? nil : sha end # Public: Gets a recursive list of Git blobs for the whole tree at the # given commit. # @@ -236,6 +240,6 @@ end path.gsub!(/\\[rn"\\]/) { |m| eval(%("#{m.to_s}")) } path end end -end \ No newline at end of file +end