Branches endpoint

Branches documentation

Fetch all branches

branches(self, project_id: str[, params=None])
Parameters:
  • project_id (str) – ID of the project to fetch branches for.

  • params (dict) – (optional) Pagination params

Returns:

Collection of branches

Example:

branches = client.branches('123.abc')
branches.items[0].branch_id # => 3456

Fetch a single branch

branch(project_id, branch_id)
Parameters:
  • project_id (str) – ID of the project

  • branch_id (int or str) – ID of the branch to fetch

Returns:

Branch model

Example:

branch = client.branch('123.abc', 34567)
branch.name # => "deutch"
branch.created_at # => "2020-04-03 14:41:46 (Etc/UTC)"

Create a branch

create_branch(project_id, params)
Parameters:
  • project_id (str) – ID of the project

  • params (dict) – Branch parameters

Returns:

Branch model

Example:

branch = client.create_branch('123.abc', {"name": "python-branch"})
branch.name # => "python-branch"

Update a branch

update_branch(project_id, branch_id, params)
Parameters:
  • project_id (str) – ID of the project

  • branch_id (int or str) – ID of the branch to update

  • params (dict) – Update parameters

Returns:

Branch model

Example:

branch = client.update_branch('123.abc', 34567, {"name": "python-branch-updated"})
branch.name # => "python-branch-updated"

Delete a branch

delete_branch(project_id, branch_id)
Parameters:
  • project_id (str) – ID of the project

  • branch_id (int or str) – ID of the branch to delete

Returns:

Dictionary with project ID and “branch_deleted” set to True

Rtype dict:

Example:

client.delete_branch('123.abc', 34567)

Merge a branch

merge_branch(project_id, branch_id[, params = None])
Parameters:
  • project_id (str) – ID of the project

  • branch_id (int or str) – ID of the source branch

  • params (dict) – Merge parameters

Returns:

Dictionary with project ID, “branch_merged” set to True, and branches info stored under the “branch” and “target_branch” keys

Rtype dict:

Example:

result = client.merge_branch('123.abc', 34567, {"force_conflict_resolve_using": "target"})
result['branch'].branch_id # => 34567
result['branch'].name # => "python-branch"
result['target_branch'].name # => "master"