Method: Gitlab::Client::RepositoryFiles#file_contents

Defined in:
lib/gitlab/client/repository_files.rb

#file_contents(project, filepath, ref = 'master') ⇒ String Also known as: repo_file_contents

Get the contents of a file

Examples:

Gitlab.file_contents(42, 'Gemfile')
Gitlab.repo_file_contents(3, 'Gemfile', 'ed899a2f4b50b4370feeea94676502b42383c746')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • filepath (String)

    The relative path of the file in the repository

  • ref (String) (defaults to: 'master')

    The name of a repository branch or tag or if not given the default branch.

Returns:

  • (String)
[View source]

19
20
21
22
23
24
25
# File 'lib/gitlab/client/repository_files.rb', line 19

def file_contents(project, filepath, ref = 'master')
  get "/projects/#{url_encode project}/repository/files/#{url_encode filepath}/raw",
      query: { ref: ref },
      format: nil,
      headers: { Accept: 'text/plain' },
      parser: ::Gitlab::Request::Parser
end