Module: Gitlab::Client::Branches

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

Overview

Defines methods related to repositories.

Instance Method Summary collapse

Instance Method Details

#branch(project, branch) ⇒ Gitlab::ObjectifiedHash Also known as: repo_branch

Gets information about a repository branch.

Examples:

Gitlab.branch(3, 'api')
Gitlab.repo_branch(5, 'master')

Parameters:

  • project (Integer)

    The ID of a project.

  • branch (String)

    The name of the branch.

Returns:



29
30
31
# File 'lib/gitlab/client/branches.rb', line 29

def branch(project, branch)
  get("/projects/#{project}/repository/branches/#{branch}")
end

#branches(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash> Also known as: repo_branches

Gets a list of project repositiory branches.

Examples:

Gitlab.branches(42)

Parameters:

  • project (Integer)

    The ID of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:



15
16
17
# File 'lib/gitlab/client/branches.rb', line 15

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

#create_branch(project, branch, ref) ⇒ Gitlab::ObjectifiedHash Also known as: repo_create_branch

Creates a repository branch. Requires Gitlab >= 6.8.x

Examples:

Gitlab.create_branch(3, 'api')
Gitlab.repo_create_branch(5, 'master')

Parameters:

  • project (Integer)

    The ID of a project.

  • branch (String)

    The name of the new branch.

  • ref (String)

    Create branch from commit sha or existing branch

Returns:



73
74
75
# File 'lib/gitlab/client/branches.rb', line 73

def create_branch(project, branch, ref)
  post("/projects/#{project}/repository/branches",:body => {:branch_name => branch, :ref => ref})
end

#delete_branch(project, branch) ⇒ Gitlab::ObjectifiedHash Also known as: repo_delete_branch

Deletes a repository branch. Requires Gitlab >= 6.8.x

Examples:

Gitlab.delete_branch(3, 'api')
Gitlab.repo_delete_branch(5, 'master')

Parameters:

  • project (Integer)

    The ID of a project.

  • branch (String)

    The name of the branch to delete

Returns:



87
88
89
# File 'lib/gitlab/client/branches.rb', line 87

def delete_branch(project, branch)
  delete("/projects/#{project}/repository/branches/#{branch}")
end

#protect_branch(project, branch) ⇒ Gitlab::ObjectifiedHash Also known as: repo_protect_branch

Protects a repository branch.

Examples:

Gitlab.protect_branch(3, 'api')
Gitlab.repo_protect_branch(5, 'master')

Parameters:

  • project (Integer)

    The ID of a project.

  • branch (String)

    The name of the branch.

Returns:



44
45
46
# File 'lib/gitlab/client/branches.rb', line 44

def protect_branch(project, branch)
  put("/projects/#{project}/repository/branches/#{branch}/protect")
end

#unprotect_branch(project, branch) ⇒ Gitlab::ObjectifiedHash Also known as: repo_unprotect_branch

Unprotects a repository branch.

Examples:

Gitlab.unprotect_branch(3, 'api')
Gitlab.repo_unprotect_branch(5, 'master')

Parameters:

  • project (Integer)

    The ID of a project.

  • branch (String)

    The name of the branch.

Returns:



58
59
60
# File 'lib/gitlab/client/branches.rb', line 58

def unprotect_branch(project, branch)
  put("/projects/#{project}/repository/branches/#{branch}/unprotect")
end