Skip to content

Commit

Permalink
temp(move --fixup): Failing test for disconnected stick
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonrcarter committed Sep 21, 2022
1 parent d5ea167 commit dda62dc
Showing 1 changed file with 131 additions and 0 deletions.
131 changes: 131 additions & 0 deletions git-branchless/tests/command/test_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5187,3 +5187,134 @@ fn test_move_fixup_tree() -> eyre::Result<()> {

Ok(())
}

#[test]
fn test_move_fixup_multiple_disconnected_into_parent() -> eyre::Result<()> {
let git = make_git()?;

if !git.supports_committer_date_is_author_date()? {
return Ok(());
}
git.init_repo()?;

git.detach_head()?;
let test1_oid = git.commit_file("test1", 1)?;
let _test2_oid = git.commit_file("test2", 2)?;
let test3_oid = git.commit_file("test3", 3)?;
let _test4_oid = git.commit_file("test4", 4)?;
let test5_oid = git.commit_file("test5", 5)?;
let _test6_oid = git.commit_file("test6", 6)?;

let (stdout, _stderr) = git.run(&["smartlog"])?;
insta::assert_snapshot!(stdout, @r###"
O f777ecc (master) create initial.txt
|
o 62fc20d create test1.txt
|
o 96d1c37 create test2.txt
|
o 70deb1e create test3.txt
|
o 355e173 create test4.txt
|
o f81d55c create test5.txt
|
@ 2831fb5 create test6.txt
"###);

let (stdout, _stderr) = git.run(&[
"show",
"--pretty=format:",
"--name-only",
&test1_oid.to_string(),
])?;
insta::assert_snapshot!(stdout, @r###"
test1.txt
"###);

// --on-disk
// FIXME on disk is not working :(
// {
// let git = git.duplicate_repo()?;
// git.run(&[
// "move",
// "--on-disk",
// "--fixup",
// "--debug-dump-rebase-plan",
// "-x",
// &test2_oid.to_string(),
// "-d",
// &test1_oid.to_string(),
// ])?;

// let (stdout, _stderr) = git.run(&["smartlog"])?;
// insta::assert_snapshot!(stdout, @r###"
// O f777ecc (master) create initial.txt
// |
// o 62fc20d create test1.txt
// |
// @ 68aa706 create test3.txt
// "###);
// }

// --in-memory
{
let (_stdout, _stderr) = git.run(&[
"move",
"--in-memory",
"--debug-dump-rebase-plan",
"--fixup",
// "--debug-dump-rebase-plan",
"-x",
&format!("{}+{}", test3_oid, test5_oid),
"-d",
&test1_oid.to_string(),
])?;
// insta::assert_snapshot!(_stderr, @r###""###);
insta::assert_snapshot!(_stdout, @r###"
Attempting rebase in-memory...
[1/3] Committed as: bf0d52a create test4.txt
[2/3] Amended as: 9ede80c create test1.txt
[3/3] Amended as: 9ede80c create test1.txt
branchless: processing 4 rewritten commits
branchless: running command: <git-executable> checkout dbc9c345de124eecad564e5de1259d7ca4eaf99b
O f777ecc (master) create initial.txt
|
o 9ede80c create test1.txt
|
o 9ede80c create test2.txt
|
o 0b465e8 create test4.txt
|
@ 0b465e8 create test6.txt
In-memory rebase succeeded.
"###);

// FIXME can we do this w/o needing to restack?
let (stdout, _stderr) = git.run(&["restack"])?;
// insta::assert_snapshot!(stderr, @r###""###);
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: 0b465e8 create test3.txt
[2/2] Committed as: 0b465e8 create test5.txt
branchless: processing 2 rewritten commits
branchless: running command: <git-executable> checkout 0b465e8fb1992620af8d4c0a44ea2c881ea2324d
In-memory rebase succeeded.
Finished restacking commits.
No abandoned branches to restack.
O f777ecc (master) create initial.txt
|
o 9ede80c create test1.txt
|
o 9ede80c create test2.txt
|
o 0b465e8 create test4.txt
|
@ 0b465e8 create test6.txt
"###);

// TODO verify contents
}

Ok(())
}

0 comments on commit dda62dc

Please sign in to comment.