Skip to content

Commit ca99202

Browse files
demo of teardown, stack branches, setup
Notice that branch `A` appears 3 times in the status output.
1 parent 17383ca commit ca99202

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

crates/but/tests/but/command/setup.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,74 @@ $ but teardown Return to normal Git mode
708708
Learn more at https://docs.gitbutler.com/cli-overview
709709
710710
711+
"#]]);
712+
713+
Ok(())
714+
}
715+
716+
#[test]
717+
fn setup_after_teardown_and_branch_rearrangement() -> anyhow::Result<()> {
718+
let env = Sandbox::init_scenario_with_target_and_default_settings("two-stacks")?;
719+
env.setup_metadata(&["A", "B"])?;
720+
721+
// Run teardown
722+
env.but("teardown").assert().success();
723+
724+
// Move B and create a new commit, and verify that the commit graph is what
725+
// we expect
726+
but_testsupport::git(&env.open_repo()?)
727+
.arg("checkout")
728+
.arg("-B")
729+
.arg("B")
730+
.output()?;
731+
but_testsupport::git(&env.open_repo()?)
732+
.env("GIT_AUTHOR_DATE", "1675176957 +0100")
733+
.env("GIT_COMMITTER_DATE", "1675176957 +0100")
734+
.arg("commit")
735+
.arg("--allow-empty")
736+
.arg("-m")
737+
.arg("New commit on branch B")
738+
.output()?;
739+
insta::assert_snapshot!(env.git_log()?, @r"
740+
* f600f85 (HEAD -> B) New commit on branch B
741+
| * c128bce (gitbutler/workspace) GitButler Workspace Commit
742+
| |\
743+
| |/
744+
|/|
745+
* | 9477ae7 (A) add A
746+
| * d3e2ba3 add B
747+
|/
748+
* 0dc3733 (origin/main, origin/HEAD, main, gitbutler/target) add M
749+
");
750+
751+
// Run setup
752+
env.but("setup").assert().success();
753+
754+
env.but("status")
755+
.assert()
756+
.success()
757+
.stderr_eq(snapbox::str![])
758+
.stdout_eq(snapbox::str![[r#"
759+
╭┄zz [unstaged changes]
760+
┊ no changes
761+
762+
┊╭┄g0 [A] (no commits)
763+
┊│
764+
┊├┄h0 [A]
765+
┊● 9477ae721ab521d9d0174f70e804ce3ff9f6fb56 add A
766+
├╯
767+
768+
┊╭┄i0 [B]
769+
┊● f600f85 New commit on branch B (no changes)
770+
┊│
771+
┊├┄j0 [A]
772+
┊● 9477ae721ab521d9d0174f70e804ce3ff9f6fb56 add A
773+
├╯
774+
775+
┴ 0dc3733 (common base) [origin/main] 2000-01-02 add M
776+
777+
Hint: run `but help` for all commands
778+
711779
"#]]);
712780

713781
Ok(())

0 commit comments

Comments
 (0)