Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): delete squash_and_merge in VersionMixin #1179

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.