Module: Gitlab::Client::Repositories

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/repositories.rb

Overview

Defines methods related to repositories.

Instance Method Summary collapse

Instance Method Details

#compare(project, from, to) ⇒ Gitlab::ObjectifiedHash Also known as: repo_compare

Compares branches, tags or commits.

Examples:

Gitlab.compare(42, 'master', 'feature/branch')
Gitlab.repo_compare(42, 'master', 'feature/branch')


50
51
52
# File 'lib/gitlab/client/repositories.rb', line 50

def compare(project, from, to)
  get("/projects/#{project}/repository/compare", query: { from: from, to: to })
end

#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')


15
16
17
18
19
20
21
# File 'lib/gitlab/client/repositories.rb', line 15

def file_contents(project, filepath, ref='master')
  ref = URI.encode(ref, /\W/)
  get "/projects/#{project}/repository/blobs/#{ref}?filepath=#{filepath}",
      format: nil,
      headers: { Accept: 'text/plain' },
      parser: ::Gitlab::Request::Parser
end

#tree(project, options = {}) ⇒ Gitlab::ObjectifiedHash Also known as: repo_tree

Get file tree project (root level).

Examples:

Gitlab.tree(42)
Gitlab.tree(42, { path: 'Gemfile' })

Options Hash (options):

  • :path (String)

    The path inside repository.

  • :ref_name (String)

    The name of a repository branch or tag.



35
36
37
# File 'lib/gitlab/client/repositories.rb', line 35

def tree(project, options={})
  get("/projects/#{project}/repository/tree", query: options)
end