Squash and Merge
TensorBay supports squashing and merging between different branches.
Before squash_and_merge()
, a dataset client instance with commits on different branches is needed.
See more details in Draft and Commit.
from tensorbay import GAS
ACCESS_KEY = "Accesskey-*****"
gas = GAS(ACCESS_KEY)
dataset_client = gas.create_dataset("DatasetName")
dataset_client.create_draft("draft-1")
dataset_client.commit("commit-1")
dataset_client.create_branch("dev")
dataset_client.create_draft("draft-2")
dataset_client.commit("commit-2")
dataset_client.create_draft("draft-3")
dataset_client.commit("commit-3")
dataset_client.checkout("main")
dataset_client.create_draft("draft-4")
dataset_client.commit("commit-4")
TensorBay SDK allows squash_and_merge()
by giving the target_branch_name
:
draft_number = dataset_client.squash_and_merge(
"draft-5",
description="description",
source_branch_name="dev",
target_branch_name="main",
strategy="override",
)
dataset_client.checkout(draft_number=draft_number)
dataset_client.commit("commit-5")
Or checkout
to the target_branch first. In this case, the current branch is main
, so we can do squash_and_merge operation directly.
draft_number = dataset_client.squash_and_merge(
"draft-5",
description="description",
source_branch_name="dev",
strategy="override",
)
dataset_client.checkout(draft_number=draft_number)
dataset_client.commit("commit-5")
Note
There are three strategies for handling the branch conflict:
“abort”: abort the opetation;
“override”: the squashed branch will override the target branch;
“skip”: keep the origin branch.