Skip to content

Commit 2c7374f

Browse files
committed
Add UI for feature flag
1 parent 26f68cf commit 2c7374f

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

apps/desktop/src/lib/backend/projects.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class Project {
2828
use_diff_context: boolean | undefined;
2929
snapshot_lines_threshold!: number | undefined;
3030
use_new_branch_integration_algorithm: boolean | undefined;
31+
use_new_integration_check!: boolean;
3132
// Produced just for the frontend to determine if the project is open in any window.
3233
is_open!: boolean;
3334

apps/desktop/src/routes/settings/experimental/+page.svelte

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
<script lang="ts">
2+
import { ProjectService, ProjectsService } from '$lib/backend/projects';
23
import {
34
cloudFunctionality,
45
cloudCommunicationFunctionality,
56
cloudReviewFunctionality
67
} from '$lib/config/uiFeatureFlags';
78
import SettingsPage from '$lib/layout/SettingsPage.svelte';
89
import { User } from '$lib/stores/user';
9-
import { getContextStore } from '@gitbutler/shared/context';
10+
import { getContext, getContextStore } from '@gitbutler/shared/context';
1011
import SectionCard from '@gitbutler/ui/SectionCard.svelte';
1112
import Toggle from '@gitbutler/ui/Toggle.svelte';
1213
1314
const user = getContextStore(User);
15+
const projectService = getContext(ProjectService);
16+
const projectsService = getContext(ProjectsService);
17+
const project = projectService.project;
18+
19+
function toggleUseNewIntegrationCheck() {
20+
const updatedProject = structuredClone($project);
21+
if (!updatedProject) return;
22+
updatedProject.use_new_integration_check = !updatedProject.use_new_integration_check;
23+
projectsService.updateProject(updatedProject);
24+
}
1425
1526
function toggleCloudFunctionality() {
1627
if ($cloudFunctionality) {
@@ -88,6 +99,20 @@
8899
</div>
89100
</div>
90101
{/if}
102+
103+
<SectionCard labelFor="newIntegrationAlgorithm" orientation="row" roundedTop={false}>
104+
{#snippet title()}New Integration Algorithm{/snippet}
105+
{#snippet caption()}
106+
A new algorithm for finding integrated commits
107+
{/snippet}
108+
{#snippet actions()}
109+
<Toggle
110+
id="newIntegrationAlgorithm"
111+
checked={$project?.use_new_integration_check}
112+
onclick={toggleUseNewIntegrationCheck}
113+
/>
114+
{/snippet}
115+
</SectionCard>
91116
</SettingsPage>
92117

93118
<style>

crates/gitbutler-branch-actions/src/integration_check.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use gitbutler_commit::commit_ext::CommitExt as _;
77
use gitbutler_oxidize::{git2_to_gix_object_id, GixRepositoryExt as _, ObjectIdExt as _, OidExt};
88
use gitbutler_repo::{signature, GixRepositoryExt};
99
use itertools::Itertools as _;
10+
use tracing::instrument;
1011

1112
use crate::commit_ops::{get_exclusive_tree, get_first_parent, is_subset, SubsetKind};
1213

@@ -377,6 +378,7 @@ impl IsCommitIntegrated<'_, '_, '_> {
377378

378379
/// Used to switch between the old and new algorithms. We will be able to
379380
/// get rid of all of this when we are confident in the new algorithm.
381+
#[instrument(skip(gix_repository, repository, graph))]
380382
pub(crate) fn compat_find_integrated_commits<'repo>(
381383
gix_repository: &'repo gix::Repository,
382384
repository: &'repo git2::Repository,

crates/gitbutler-project/src/storage.rs

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct UpdateRequest {
2828
pub use_diff_context: Option<bool>,
2929
pub snapshot_lines_threshold: Option<usize>,
3030
pub use_new_branch_integration_algorithm: Option<bool>,
31+
pub use_new_integration_check: Option<bool>,
3132
}
3233

3334
impl Storage {
@@ -130,6 +131,10 @@ impl Storage {
130131
project.use_new_branch_integration_algorithm = Some(new_branch_integration_algorithm);
131132
}
132133

134+
if let Some(use_new_integration_check) = update_request.use_new_integration_check {
135+
project.use_new_integration_check = use_new_integration_check;
136+
}
137+
133138
self.inner
134139
.write(PROJECTS_FILE, &serde_json::to_string_pretty(&projects)?)?;
135140

0 commit comments

Comments
 (0)