Skip to content

Commit

Permalink
test: add scenario for re-ordering branches
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Jan 18, 2024
1 parent 6f6f587 commit 8407916
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
parent = os.path.dirname(__file__)
sys.path.append(parent)

from gitstack import CreateCommand, RebaseCommand, git, print_err, run
from gitstack import CreateCommand, DiffLabel, RebaseCommand, git, print_err, run


def add_test_file(filename: str) -> None:
with open(filename, "w") as f:
with open(filename, "w", encoding="utf-8") as f:
f.write("This is a test file\n")
run("git", "add", filename)

Expand Down Expand Up @@ -63,6 +63,19 @@ def run_cmd(args: argparse.Namespace) -> None:
git.commit("Merge " + test_branch_name + "-1")
git.switch_branch(test_branch_name + "-3")
RebaseCommand().run(git.get_main_branch())
elif args.test_cmd == "reorder":
git.create_branch(test_branch_name + "-1")
add_test_file("test1.txt")
git.commit("Test commit 1")
git.create_branch(test_branch_name + "-2", "HEAD")
add_test_file("test2.txt")
git.commit("Test commit 2")
git.label_commit("HEAD", DiffLabel(test_branch_name + "-3"))
git.create_branch(test_branch_name + "-3", "HEAD")
add_test_file("test3.txt")
git.commit("Test commit 3")
git.label_commit("HEAD", DiffLabel(test_branch_name + "-1"))
CreateCommand().run()

# elif args.test_cmd == "tidy_stack":
# git.create_branch(test_branch_name)
Expand Down Expand Up @@ -111,6 +124,7 @@ def main() -> None:
"rebase_cleanup",
"merge_squash",
"create",
"reorder",
# "tidy_stack",
# "tidy_rebase",
# "old_stack",
Expand Down

0 comments on commit 8407916

Please sign in to comment.