Skip to content

Commit

Permalink
feat(client): delete squash_and_merge in VersionMixin
Browse files Browse the repository at this point in the history
PR Closed: #1179
  • Loading branch information
graczhual committed Dec 22, 2021
1 parent 1203df1 commit 48a48ab
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 346 deletions.
56 changes: 0 additions & 56 deletions docs/code/squash_and_merge.py

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/features/version_control/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ TensorBay supports dataset version control. There can be multiple versions in on
:caption: Advanced Operations

diff
squash_and_merge
42 changes: 0 additions & 42 deletions docs/source/features/version_control/squash_and_merge.rst

This file was deleted.

2 changes: 1 addition & 1 deletion tensorbay/client/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def cache_enabled(self) -> bool:

@property # type: ignore[misc]
@functools.lru_cache()
def squash_and_merges(self) -> SquashAndMerge:
def squash_and_merge(self) -> SquashAndMerge:
"""Get class :class:`~tensorbay.client.version.SquashAndMerge`.
Returns:
Expand Down
23 changes: 0 additions & 23 deletions tensorbay/client/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,3 @@ class TestVersionControlMixin:
alias="",
is_public=DEFAULT_IS_PUBLIC,
)

def test_squash_and_merge(self, mocker):
post_data = {
"title": "squash_merge-1",
"sourceBranchName": "branch-1",
"targetBranchName": "branch-2",
"strategy": "abort",
}
response_data = {"draftNumber": 2}
open_api_do = mocker.patch(
f"{gas.__name__}.Client.open_api_do",
return_value=mock_response(data=response_data),
)
draft_number = self.dataset_client.squash_and_merge(
"squash_merge-1",
source_branch_name="branch-1",
target_branch_name="branch-2",
strategy="abort",
)
open_api_do.assert_called_once_with(
"POST", "squashAndMerge", self.dataset_client.dataset_id, json=post_data
)
assert draft_number == 2
61 changes: 0 additions & 61 deletions tensorbay/client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,67 +309,6 @@ def close_draft(self, number: int) -> None:

self._close_draft(number)

def squash_and_merge(
self,
title: str,
description: str = "",
*,
source_branch_name: str,
target_branch_name: Optional[str] = None,
strategy: Optional[str] = "abort",
) -> int:
"""Squash and merge.
Squash commits in source branch, then merge into target branch by creating a new draft.
If the target branch name is not given, the draft will be based on the branch name stored
in the dataset client. And during merging, the conflicts between branches can be resolved
in three different strategies: "abort", "override" and "skip".
Arguments:
title: The draft title.
description: The draft description.
source_branch_name: The name of the branch to be squashed.
target_branch_name: The target branch name of the merge operation.
strategy: The strategy of handling the branch conflict. There are three options:
1. "abort": abort the opetation;
2. "override": the squashed branch will override the target branch;
3. "skip": keep the origin branch.
Raises:
StatusError: When squashing and merging without basing on a branch.
Returns:
The draft number of the new draft.
"""
if not target_branch_name:
target_branch_name = self._status.branch_name
if not target_branch_name:
raise StatusError(
message="Squash and merge without basing on a branch is not allowed"
)
self._status.check_authority_for_commit()

post_data: Dict[str, Any] = {
"title": title,
"sourceBranchName": source_branch_name,
"targetBranchName": target_branch_name,
"strategy": strategy,
}

if description:
post_data["description"] = description

response = self._client.open_api_do(
"POST", "squashAndMerge", self._dataset_id, json=post_data
)
draft_number: int = response.json()["draftNumber"]

self._status.checkout(draft_number=draft_number)
self._status.branch_name = target_branch_name
return draft_number

def get_commit(self, revision: Optional[str] = None) -> Commit:
"""Get the certain commit with the given revision.
Expand Down
162 changes: 0 additions & 162 deletions tests/test_squash_and_merge.py

This file was deleted.

0 comments on commit 48a48ab

Please sign in to comment.