Skip to content

Commit ca6e664

Browse files
authored
Merge pull request #13150 from Byron/multi-process-safety
Re-enable modern-but testing
2 parents bccd34a + 7e3e923 commit ca6e664

File tree

8 files changed

+46
-10
lines changed

8 files changed

+46
-10
lines changed

.github/workflows/push.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ jobs:
220220
cargo check -p but-workspace --all-targets
221221
cargo check -p but-api --all-targets
222222
cargo check -p but --all-targets
223+
make check-modern-but
223224
name: Special `cargo check` runs
224225
env:
225226
RUSTFLAGS: "--deny warnings"
@@ -302,6 +303,7 @@ jobs:
302303
- run: cargo test --workspace --exclude gitbutler-tauri --exclude but-server --exclude but-api-macros-tests
303304
# It's intentional to use 'name equals run-script' so it's easy to re-run locally on failure.
304305
- run: cargo test -p but
306+
- run: make test-modern-but
305307
- run: cargo test -p but-server
306308
- name: test vendored
307309
run: |

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ check:
2828
clippy:
2929
cargo clippy --workspace --all-targets -- -D warnings
3030

31+
# An alias for nextest
3132
.PHONY: test
3233
test: nextest
3334

35+
# CI executes this to build a version of `but` without any legacy code.
36+
.PHONY: check-modern-but
37+
check-modern-but:
38+
cargo check -p but --all-targets --no-default-features
39+
40+
# CI executes this to test a version of `but` without any legacy code.
41+
.PHONY: test-modern-but
42+
test-modern-but:
43+
cargo test -p but --no-default-features
44+
3445
# Run all tests in the entire workspace and show all failures in the end.
3546
.PHONY: nextest
3647
nextest:

crates/but/src/args/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use super::*;
22

3+
#[cfg(feature = "legacy")]
34
mod commit;
5+
#[cfg(feature = "legacy")]
46
mod reword;
57

68
mod config_ai {

crates/but/src/command/commit/file.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
use crate::utils::OutputChannel;
12
use anyhow::{Context as _, Result};
23
use bstr::BStr;
34
use bstr::ByteSlice;
45
use but_core::{DiffSpec, diff::tree_changes, sync::RepoExclusive};
56
use but_ctx::Context;
6-
use gitbutler_branch_actions::update_workspace_commit;
7-
8-
use crate::utils::OutputChannel;
97

108
pub fn commited_file_to_another_commit(
119
ctx: &mut Context,
@@ -43,7 +41,7 @@ pub fn commited_file_to_another_commit_with_perm(
4341
perm,
4442
)?;
4543

46-
update_workspace_commit(ctx, false)?;
44+
legacy_update_workspace_commit(ctx)?;
4745

4846
if let Some(out) = out.for_human() {
4947
writeln!(out, "Moved files between commits!")?;
@@ -92,7 +90,7 @@ pub fn uncommit_file_with_perm(
9290
perm,
9391
)?;
9492

95-
update_workspace_commit(ctx, false)?;
93+
legacy_update_workspace_commit(ctx)?;
9694

9795
if let Some(out) = out.for_human() {
9896
writeln!(out, "Uncommitted changes")?;
@@ -140,10 +138,12 @@ pub fn uncommit_file_and_discard_with_perm(
140138
perm,
141139
)?;
142140

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+
};
145145

146-
update_workspace_commit(ctx, false)?;
146+
legacy_update_workspace_commit(ctx)?;
147147

148148
if emit_output {
149149
if let Some(out) = out.for_human() {
@@ -197,3 +197,11 @@ fn find_stack_id_for_branch_with_perm(
197197
.and_then(|(stack, _)| stack.id);
198198
Ok(assign_to)
199199
}
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+
}

crates/but/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ use but_settings::AppSettings;
3737
use colored::Colorize;
3838
use gix::date::time::CustomFormat;
3939

40+
#[cfg(feature = "legacy")]
41+
use crate::command::legacy::ShowDiffInEditor;
4042
use crate::{
41-
command::legacy::ShowDiffInEditor,
4243
setup::{BackgroundSync, InitCtxOptions},
4344
utils::{
4445
OneshotMetricsContext, OutputChannel, ResultErrorExt, ResultJsonExt, ResultMetricsExt,
@@ -1488,6 +1489,16 @@ async fn maybe_run_status_after(
14881489
}
14891490
}
14901491

1492+
/// Ignore `--status-after` in non-legacy builds until a non-legacy status command exists.
1493+
#[cfg(not(feature = "legacy"))]
1494+
async fn maybe_run_status_after(
1495+
_status_after: bool,
1496+
_result: &anyhow::Result<()>,
1497+
_ctx: &mut but_ctx::Context,
1498+
_out: &mut OutputChannel,
1499+
) {
1500+
}
1501+
14911502
/// Run workspace status output after a mutation command completes.
14921503
///
14931504
/// In human mode, prints a blank line then full status.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod apply;
22
mod move_branch;
3-
#[cfg(feature = "legacy")]
43
mod new;
54
mod tear_off;
65
mod unapply;

crates/but/tests/but/command/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn ai_openai_defaults_to_global_config() -> anyhow::Result<()> {
3737
fn ai_ollama_local_writes_repo_config() -> anyhow::Result<()> {
3838
let env = Sandbox::empty()?;
3939
env.invoke_bash("git init repo");
40+
#[cfg(feature = "legacy")]
4041
env.but("-C repo setup").assert().success();
4142

4243
env.but("-C repo config ai --local ollama --endpoint localhost:11434 --model llama3.1")
@@ -113,6 +114,7 @@ fn ai_show_outputs_current_global_configuration_json() -> anyhow::Result<()> {
113114
fn ai_show_outputs_current_local_configuration_json() -> anyhow::Result<()> {
114115
let env = Sandbox::empty()?;
115116
env.invoke_bash("git init repo");
117+
#[cfg(feature = "legacy")]
116118
env.but("-C repo setup").assert().success();
117119

118120
env.but("-C repo config ai --local ollama --endpoint localhost:11434 --model llama3.1")

crates/but/tests/but/command/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#[cfg(feature = "legacy")]
55
mod absorb;
66
mod alias;
7+
#[cfg(feature = "legacy")]
78
mod branch;
89
#[cfg(feature = "legacy")]
910
mod claude;

0 commit comments

Comments
 (0)