Skip to content

Commit

Permalink
temp(move --fixup): Apply backup tag before fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonrcarter committed Dec 10, 2022
1 parent d2b07b1 commit 282023b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
14 changes: 14 additions & 0 deletions git-branchless-move/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,20 @@ pub fn r#move(
resolve_merge_conflicts,
check_out_commit_options: Default::default(),
};

if fixup {
// FIXME this is just backup/debugging; remove before merge!
let tag_name = format!(
"pre-fixup-{}",
now.duration_since(SystemTime::UNIX_EPOCH)?.as_secs()
);
let exit_code =
git_run_info.run(effects, Some(event_tx_id), &["tag", &tag_name])?;
if !exit_code.is_success() {
return Ok(exit_code);
}
}

execute_rebase_plan(
effects,
git_run_info,
Expand Down
14 changes: 13 additions & 1 deletion git-branchless/tests/test_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4643,6 +4643,7 @@ fn test_move_fixup_head_into_parent() -> eyre::Result<()> {
"-d",
&test2_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/1] Committed as: 8c3aa56 update 2 test.txt
Expand Down Expand Up @@ -4749,6 +4750,7 @@ fn test_move_fixup_parent_into_head() -> eyre::Result<()> {
"-x",
&test2_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/1] Committed as: ff6183f update 3 test.txt
Expand Down Expand Up @@ -4869,6 +4871,7 @@ fn test_move_fixup_head_into_ancestor() -> eyre::Result<()> {
"-d",
&test1_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: 963fb93 create test.txt
Expand Down Expand Up @@ -4993,7 +4996,7 @@ fn test_move_fixup_ancestor_into_head() -> eyre::Result<()> {
&test2_oid.to_string(),
])?;

// let stdout = format!("{}{}", _stderr, stdout);
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: dbcd17a update 3 test.txt
Expand Down Expand Up @@ -5106,6 +5109,7 @@ fn test_move_fixup_multiple_into_head() -> eyre::Result<()> {
"-x",
&format!("{}+{}", test1_oid, test2_oid),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/1] Committed as: c4f6746 update 3 test.txt
Expand Down Expand Up @@ -5242,6 +5246,7 @@ fn test_move_fixup_multiple_into_ancestor_with_unmoved_head() -> eyre::Result<()
"-d",
&test1_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: 23d4bdd create test.txt
Expand Down Expand Up @@ -5478,6 +5483,7 @@ fn test_move_fixup_multiple_disconnected_into_ancestor() -> eyre::Result<()> {
"-d",
&test1_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/4] Committed as: 38caaaf create test.txt
Expand Down Expand Up @@ -5724,6 +5730,7 @@ fn test_move_fixup_multiple_disconnected_into_head() -> eyre::Result<()> {
"-x",
&format!("{}+{}", test3_oid, test5_oid),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: c21e0d7 update 4 test.txt
Expand Down Expand Up @@ -5869,6 +5876,7 @@ fn test_move_fixup_squash_branch() -> eyre::Result<()> {
"-d",
&test1_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/1] Committed as: c513440 create test.txt
Expand Down Expand Up @@ -6021,6 +6029,7 @@ fn test_move_fixup_branch_tip() -> eyre::Result<()> {
"-d",
&test1_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/2] Committed as: f4321df create test.txt
Expand Down Expand Up @@ -6269,6 +6278,7 @@ fn test_move_fixup_tree() -> eyre::Result<()> {
"-d",
&test4_oid.to_string(),
])?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
[1/3] Committed as: 5e6d3e4 update 7 test.txt
Expand Down Expand Up @@ -6350,6 +6360,7 @@ fn test_move_fixup_conflict() -> eyre::Result<()> {
},
)?;

let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
branchless: running command: <git-executable> diff --quiet
Calling Git for on-disk rebase...
Expand All @@ -6376,6 +6387,7 @@ fn test_move_fixup_conflict() -> eyre::Result<()> {
..Default::default()
},
)?;
let stdout = stdout.as_str().split_once('\n').unwrap_or_default().1;
insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
This operation would cause a merge conflict:
Expand Down

0 comments on commit 282023b

Please sign in to comment.