|
| 1 | +use crate::utils::OutputChannel; |
1 | 2 | use anyhow::{Context as _, Result}; |
2 | 3 | use bstr::BStr; |
3 | 4 | use bstr::ByteSlice; |
4 | 5 | use but_core::{DiffSpec, diff::tree_changes, sync::RepoExclusive}; |
5 | 6 | use but_ctx::Context; |
6 | | -use gitbutler_branch_actions::update_workspace_commit; |
7 | | - |
8 | | -use crate::utils::OutputChannel; |
9 | 7 |
|
10 | 8 | pub fn commited_file_to_another_commit( |
11 | 9 | ctx: &mut Context, |
@@ -43,7 +41,7 @@ pub fn commited_file_to_another_commit_with_perm( |
43 | 41 | perm, |
44 | 42 | )?; |
45 | 43 |
|
46 | | - update_workspace_commit(ctx, false)?; |
| 44 | + legacy_update_workspace_commit(ctx)?; |
47 | 45 |
|
48 | 46 | if let Some(out) = out.for_human() { |
49 | 47 | writeln!(out, "Moved files between commits!")?; |
@@ -92,7 +90,7 @@ pub fn uncommit_file_with_perm( |
92 | 90 | perm, |
93 | 91 | )?; |
94 | 92 |
|
95 | | - update_workspace_commit(ctx, false)?; |
| 93 | + legacy_update_workspace_commit(ctx)?; |
96 | 94 |
|
97 | 95 | if let Some(out) = out.for_human() { |
98 | 96 | writeln!(out, "Uncommitted changes")?; |
@@ -140,10 +138,12 @@ pub fn uncommit_file_and_discard_with_perm( |
140 | 138 | perm, |
141 | 139 | )?; |
142 | 140 |
|
143 | | - let repo = ctx.repo.get()?; |
144 | | - let dropped = but_workspace::discard_workspace_changes(&repo, relevant_changes, context_lines)?; |
| 141 | + let dropped = { |
| 142 | + let repo = ctx.repo.get()?; |
| 143 | + but_workspace::discard_workspace_changes(&repo, relevant_changes, context_lines)? |
| 144 | + }; |
145 | 145 |
|
146 | | - update_workspace_commit(ctx, false)?; |
| 146 | + legacy_update_workspace_commit(ctx)?; |
147 | 147 |
|
148 | 148 | if emit_output { |
149 | 149 | if let Some(out) = out.for_human() { |
@@ -197,3 +197,11 @@ fn find_stack_id_for_branch_with_perm( |
197 | 197 | .and_then(|(stack, _)| stack.id); |
198 | 198 | Ok(assign_to) |
199 | 199 | } |
| 200 | + |
| 201 | +/// Refresh the workspace commit when legacy workspace state is available. |
| 202 | +/// TODO: remove this as it shouldn't be needed - all the functions it calls use the rebase engine which takes care of that. |
| 203 | +fn legacy_update_workspace_commit(_ctx: &mut Context) -> Result<()> { |
| 204 | + #[cfg(feature = "legacy")] |
| 205 | + gitbutler_branch_actions::update_workspace_commit(_ctx, false)?; |
| 206 | + Ok(()) |
| 207 | +} |
0 commit comments