module Gitlab::Client::Repositories

Defines methods related to repositories. @see docs.gitlab.com/ce/api/repositories.html

Public Instance Methods

compare(project, from, to) click to toggle source

Compares branches, tags or commits.

@example

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

@param [Integer] project The ID of a project. @param [String] from The commit SHA or branch name of from branch. @param [String] to The commit SHA or branch name of to branch. @return [Gitlab::ObjectifiedHash]

# File lib/gitlab/client/repositories.rb, line 58
def compare(project, from, to)
  get("/projects/#{url_encode project}/repository/compare", query: { from: from, to: to })
end
Also aliased as: repo_compare
contributors(project, options = {}) click to toggle source

Get project repository contributors.

@example

Gitlab.contributors(42)
Gitlab.contributors(42, { order: 'name' })

@param [Integer, String] project The ID or name of a project. @param [Hash] options A customizable set of options. @option options [String] :order_by Order by name, email or commits (default = commits). @option options [String] :sort Sort order asc or desc (default = asc). @return [Array<Gitlab::ObjectifiedHash>]

# File lib/gitlab/client/repositories.rb, line 87
def contributors(project, options = {})
  get("/projects/#{url_encode project}/repository/contributors", query: options)
end
Also aliased as: repo_contributors
merge_base(project, refs) click to toggle source

Get the common ancestor for 2 refs (commit SHAs, branch names or tags).

@example

Gitlab.merge_base(42, ['master', 'feature/branch'])
Gitlab.merge_base(42, ['master', 'feature/branch'])

@param [Integer, String] project The ID or URL-encoded path of the project. @param [Array] refs Array containing 2 commit SHAs, branch names, or tags. @return [Gitlab::ObjectifiedHash]

# File lib/gitlab/client/repositories.rb, line 72
def merge_base(project, refs)
  get("/projects/#{url_encode project}/repository/merge_base", query: { refs: refs })
end
repo_archive(project, ref = 'master', format = 'tar.gz') click to toggle source

Get project repository archive

@example

Gitlab.repo_archive(42)
Gitlab.repo_archive(42, 'deadbeef')

@param [Integer, String] project The ID or name of a project. @param [String] ref The commit sha, branch, or tag to download. @param [String] format The archive format. Options are: tar.gz (default), tar.bz2, tbz, tbz2, tb2, bz2, tar, and zip @return [Gitlab::FileResponse]

# File lib/gitlab/client/repositories.rb, line 34
def repo_archive(project, ref = 'master', format = 'tar.gz')
  get("/projects/#{url_encode project}/repository/archive.#{format}",
      format: nil,
      headers: { Accept: 'application/octet-stream' },
      query: { sha: ref },
      parser: proc { |body, _|
        if body.encoding == Encoding::ASCII_8BIT # binary response
          ::Gitlab::FileResponse.new StringIO.new(body, 'rb+')
        else # error with json response
          ::Gitlab::Request.parse(body)
        end
      })
end
repo_compare(project, from, to)
Alias for: compare
repo_contributors(project, options = {})
Alias for: contributors
repo_tree(project, options = {})
Alias for: tree
tree(project, options = {}) click to toggle source

Get file tree project (root level).

@example

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

@param [Integer, String] project The ID or name of a project. @param [Hash] options A customizable set of options. @option options [String] :path The path inside repository. @option options [String] :ref The name of a repository branch or tag. @option options [Integer] :per_page Number of results to show per page (default = 20) @return [Gitlab::ObjectifiedHash]

# File lib/gitlab/client/repositories.rb, line 19
def tree(project, options = {})
  get("/projects/#{url_encode project}/repository/tree", query: options)
end
Also aliased as: repo_tree