Method: Commit#uri_type

Defined in:
app/models/commit.rb

#uri_type(path) ⇒ Object

Get the URI type of the given path

Used to build URLs to files in the repository in GFM.

path - String path to check

Examples:

uri_type('doc/README.md') # => :blob
uri_type('doc/logo.png')  # => :raw
uri_type('doc/api')       # => :tree
uri_type('not/found')     # => nil

Returns a symbol



492
493
494
495
496
497
498
499
500
501
502
# File 'app/models/commit.rb', line 492

def uri_type(path)
  entry = @raw.tree_entry(path)
  return unless entry

  if entry[:type] == :blob
    blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), container)
    blob.image? || blob.video? || blob.audio? ? :raw : :blob
  else
    entry[:type]
  end
end