Skip to content

Commit

Permalink
feat(client): adapt openAPI "createBranch"
Browse files Browse the repository at this point in the history
PR Closed: #613
  • Loading branch information
rexzheng324-c committed Jun 1, 2021
1 parent ce8a936 commit 64c155d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tensorbay/client/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ def list_tags(self) -> PagingList[Tag]:
"""
return PagingList(lambda offset, limit: self._generate_tags(None, offset, limit), 128)

def create_branch(self, name: str, revision: Optional[str] = None) -> None:
"""Create the branch.
Arguments:
name: The branch name.
revision: The information to locate the specific commit, which can be the commit id,
the branch name, or the tag name.
If the revision is not given, create the branch based on the current commit.
"""
if not revision:
self._status.check_authority_for_commit()
revision = self._status.commit_id

post_data: Dict[str, Any] = {"name": name, "commit": revision}
self._client.open_api_do("POST", "branches", self.dataset_id, json=post_data)

def get_branch(self, name: str) -> Branch:
"""Get the branch with the given name.
Expand Down

0 comments on commit 64c155d

Please sign in to comment.