Skip to content

Commit ec09647

Browse files
authored
Merge pull request #10357 from Byron/fix
Improve defaults after settings.json was deleted + recreated
2 parents 99b0d30 + a3fec9e commit ec09647

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

crates/but-settings/assets/defaults.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
},
2020
"featureFlags": {
2121
// Deprecated, was used for the new version of the UI.
22-
"v3": false,
22+
"v3": true,
2323
// Enables the v3 safe checkout.
2424
"cv3": false,
2525
/// Enable the usage of V3 workspace APIs.
26-
"ws3": false,
26+
"ws3": true,
2727
/// Enable undo/redo support.
2828
"undo": false,
2929
/// Enable the usage of GitButler Acitions.

crates/gitbutler-branch-actions/tests/reorder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ fn file(ctx: &CommandContext, commit_id: gix::ObjectId) -> String {
469469
}
470470

471471
fn command_ctx(name: &str) -> Result<(CommandContext, TempDir)> {
472-
gitbutler_testsupport::writable::fixture("reorder.sh", name)
472+
gitbutler_testsupport::writable::fixture_with_settings("reorder.sh", name, |settings| {
473+
settings.feature_flags.ws3 = false
474+
})
473475
}
474476

475477
fn test_ctx(ctx: &CommandContext) -> Result<TestContext> {

crates/gitbutler-branch-actions/tests/virtual_branches/create_virtual_branch_from_branch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use super::*;
77

88
#[test]
99
fn integration() {
10-
let Test { repo, ctx, .. } = &Test::default();
10+
let Test { repo, ctx, .. } =
11+
&Test::new_with_settings(|settings| settings.feature_flags.ws3 = false);
1112

1213
gitbutler_branch_actions::set_base_branch(
1314
ctx,

crates/gitbutler-branch-actions/tests/virtual_branches/mod.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,17 @@ struct Test {
1818
ctx: CommandContext,
1919
}
2020

21-
impl Drop for Test {
22-
fn drop(&mut self) {
23-
if std::env::var_os(VAR_NO_CLEANUP).is_some() {
24-
let _ = self.data_dir.take().unwrap().keep();
25-
}
26-
}
27-
}
28-
29-
impl Default for Test {
30-
fn default() -> Self {
21+
impl Test {
22+
pub fn new_with_settings(change_settings: fn(&mut AppSettings)) -> Self {
3123
let data_dir = paths::data_dir();
3224

3325
let test_project = TestProject::default();
3426
let outcome = gitbutler_project::add_with_path(data_dir.as_ref(), test_project.path())
3527
.expect("failed to add project");
3628
let project = outcome.unwrap_project();
37-
let ctx = CommandContext::open(&project, AppSettings::default()).unwrap();
29+
let mut settings = AppSettings::default();
30+
change_settings(&mut settings);
31+
let ctx = CommandContext::open(&project, settings).unwrap();
3832

3933
Self {
4034
repo: test_project,
@@ -46,6 +40,20 @@ impl Default for Test {
4640
}
4741
}
4842

43+
impl Drop for Test {
44+
fn drop(&mut self) {
45+
if std::env::var_os(VAR_NO_CLEANUP).is_some() {
46+
let _ = self.data_dir.take().unwrap().keep();
47+
}
48+
}
49+
}
50+
51+
impl Default for Test {
52+
fn default() -> Self {
53+
Self::new_with_settings(|_settings| {})
54+
}
55+
}
56+
4957
impl Test {
5058
/// Consume this instance and keep the temp directory that held the local repository, returning it.
5159
/// Best used inside a `dbg!(test.debug_local_repo())`

crates/gitbutler-testsupport/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ pub mod writable {
8080
pub fn fixture(
8181
script_name: &str,
8282
project_directory: &str,
83+
) -> anyhow::Result<(CommandContext, TempDir)> {
84+
fixture_with_settings(script_name, project_directory, |_| {})
85+
}
86+
pub fn fixture_with_settings(
87+
script_name: &str,
88+
project_directory: &str,
89+
change_settings: fn(&mut AppSettings),
8390
) -> anyhow::Result<(CommandContext, TempDir)> {
8491
let (project, tempdir) = fixture_project(script_name, project_directory)?;
85-
let open = CommandContext::open(&project, AppSettings::default());
92+
let mut settings = AppSettings::default();
93+
change_settings(&mut settings);
94+
let open = CommandContext::open(&project, settings);
8695
let ctx = open?;
8796
Ok((ctx, tempdir))
8897
}

0 commit comments

Comments
 (0)