module Gitlab::Client::Branches

def branch(project, branch)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • branch (String) -- The name of the branch.
  • project (Integer, String) -- The ID or name of a project.
def branch(project, branch)
  get("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
end

def branches(project, options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :per_page (Integer) -- The number of results per page.
  • :page (Integer) -- The page number.

Parameters:
  • options (Hash) -- A customizable set of options.
  • project (Integer, String) -- The ID or name of a project.
def branches(project, options = {})
  get("/projects/#{url_encode project}/repository/branches", query: options)
end

def create_branch(project, branch, ref)

Returns:
  • (Gitlab::ObjectifiedHash) - Details about the branch

Parameters:
  • ref (String) -- Create branch from commit sha or existing branch
  • branch (String) -- The name of the new branch.
  • project (Integer, String) -- The ID or name of a project.
def create_branch(project, branch, ref)
  post("/projects/#{url_encode project}/repository/branches", query: { branch: branch, ref: ref })
end

def delete_branch(project, branch)

Parameters:
  • branch (String) -- The name of the branch to delete
  • project (Integer, String) -- The ID or name of a project.
def delete_branch(project, branch)
  delete("/projects/#{url_encode project}/repository/branches/#{url_encode branch}")
end

def delete_merged_branches(project)

Returns:
  • (nil) - This API call returns an empty response body.

Parameters:
  • project (Integer, String) -- The ID or name of a project.
def delete_merged_branches(project)
  delete("/projects/#{url_encode project}/repository/merged_branches")
end

def protect_branch(project, branch, options = {})

Returns:
  • (Gitlab::ObjectifiedHash) - Details about the branch

Options Hash: (**options)
  • :developers_can_merge (Boolean) -- True to allow developers to merge into the branch (default = false)
  • :developers_can_push (Boolean) -- True to allow developers to push to the branch (default = false)

Parameters:
  • options (Hash) -- A customizable set of options.
  • branch (String) -- The name of the branch.
  • project (Integer, String) -- The ID or name of a project.
def protect_branch(project, branch, options = {})
  post("/projects/#{url_encode project}/protected_branches", body: { name: branch }.merge(options))
end

def protected_branch(project, branch)

Returns:
  • (Gitlab::ObjectifiedHash) -

Parameters:
  • name (String) -- The name of the branch or wildcard
  • project (Integer, String) -- The ID or name of a project.
def protected_branch(project, branch)
  get("/projects/#{url_encode project}/protected_branches/#{url_encode branch}")
end

def protected_branches(project)

Returns:
  • (Array) -

Parameters:
  • project (Integer, String) -- The ID or name of a project.
def protected_branches(project)
  get("/projects/#{url_encode project}/protected_branches")
end

def unprotect_branch(project, branch)

Returns:
  • (Gitlab::ObjectifiedHash) - Details about the branch

Parameters:
  • branch (String) -- The name of the branch.
  • project (Integer, String) -- The ID or name of a project.
def unprotect_branch(project, branch)
  delete("/projects/#{url_encode project}/protected_branches/#{url_encode branch}")
end