Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/desktop/cypress/e2e/support/mock/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const MOCK_TELEMETRY_SETINGS: TelemetrySettings = {
};

export const MOCK_FEATURE_FLAGS: FeatureFlags = {
ws3: false,
actions: false,
butbot: false,
rules: false
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/src/components/AnalyticsMonitor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ attached to posthog events.
eventContext.update({
v3: true,
butlerActions: $settingsService?.featureFlags.actions,
ws3: $settingsService?.featureFlags.ws3,
rules: $settingsService?.featureFlags.rules
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,6 @@
/>
{/snippet}
</SectionCard>
<SectionCard labelFor="ws3" roundedTop={false} roundedBottom={false} orientation="row">
{#snippet title()}
New workspace backend
{/snippet}
{#snippet caption()}
Enable this to use the new API for rendering the workspace state. This should correctly detect
squash-merged PRs as integrated when updating the workspace.
{/snippet}
{#snippet actions()}
<Toggle
id="ws3"
checked={$settingsStore?.featureFlags.ws3}
onclick={() =>
settingsService.updateFeatureFlags({ ws3: !$settingsStore?.featureFlags.ws3 })}
/>
{/snippet}
</SectionCard>
<SectionCard labelFor="rules" roundedTop={false} orientation="row">
{#snippet title()}
Workspace Rules
Expand Down
2 changes: 0 additions & 2 deletions apps/desktop/src/lib/config/appSettingsV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export type TelemetrySettings = {
};

export type FeatureFlags = {
/** Enable the usage of the V3 workspace API */
ws3: boolean;
/** Enable the usage of GitButler Acitions. */
actions: boolean;
/** Enable the usage of butbot chat */
Expand Down
9 changes: 0 additions & 9 deletions apps/desktop/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import { BranchService, BRANCH_SERVICE } from '$lib/branches/branchService.svelte';
import { CommitService, COMMIT_SERVICE } from '$lib/commits/commitService.svelte';
import { APP_SETTINGS } from '$lib/config/appSettings';
import { SETTINGS_SERVICE } from '$lib/config/appSettingsV2';
import { GIT_CONFIG_SERVICE } from '$lib/config/gitConfigService';
import { ircEnabled, ircServer } from '$lib/config/uiFeatureFlags';
import DependencyService, {
Expand Down Expand Up @@ -238,7 +237,6 @@
provide(ORGANIZATION_SERVICE, organizationService);
provide(CLOUD_USER_SERVICE, cloudUserService);
provide(HOOKS_SERVICE, data.hooksService);
provide(SETTINGS_SERVICE, data.settingsService);
provide(FILE_SERVICE, data.fileService);
provide(COMMIT_SERVICE, commitService);

Expand Down Expand Up @@ -272,9 +270,6 @@
provide(RESIZE_SYNC, new ResizeSync());
provide(GIT_SERVICE, new GitService(data.tauri));

const settingsService = data.settingsService;
const settingsStore = settingsService.appSettings;

// Special initialization to capture pageviews for single page apps.
if (browser) {
beforeNavigate(() => data.posthog.capture('$pageleave'));
Expand Down Expand Up @@ -304,10 +299,6 @@
});

const handleKeyDown = createKeybind({
// Toggle v3 workspace APIs on/off
'w s 3': () => {
settingsService.updateFeatureFlags({ ws3: !$settingsStore?.featureFlags.ws3 });
},
// This is a debug tool to see how the commit-graph looks like, the basis for all workspace computation.
// For good measure, it also shows the workspace.
'd o t': async () => {
Expand Down
14 changes: 2 additions & 12 deletions crates/but-action/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,8 @@ fn default_target_setting_if_none(
}

fn stacks(ctx: &CommandContext, repo: &gix::Repository) -> anyhow::Result<Vec<StackEntry>> {
let project = ctx.project();
if ctx.app_settings().feature_flags.ws3 {
let meta = ref_metadata_toml(ctx.project())?;
but_workspace::stacks_v3(repo, &meta, but_workspace::StacksFilter::InWorkspace)
} else {
but_workspace::stacks(
ctx,
&project.gb_dir(),
repo,
but_workspace::StacksFilter::InWorkspace,
)
}
let meta = ref_metadata_toml(ctx.project())?;
but_workspace::stacks_v3(repo, &meta, but_workspace::StacksFilter::InWorkspace)
}

fn ref_metadata_toml(project: &Project) -> anyhow::Result<VirtualBranchesTomlMetadata> {
Expand Down
12 changes: 4 additions & 8 deletions crates/but-action/src/reword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,8 @@ pub async fn commit(

fn stacks(ctx: &CommandContext) -> anyhow::Result<Vec<StackEntry>> {
let repo = ctx.gix_repo_for_merging_non_persisting()?;
if ctx.app_settings().feature_flags.ws3 {
let meta = VirtualBranchesTomlMetadata::from_path(
ctx.project().gb_dir().join("virtual_branches.toml"),
)?;
but_workspace::stacks_v3(&repo, &meta, StacksFilter::default())
} else {
but_workspace::stacks(ctx, &ctx.project().gb_dir(), &repo, StacksFilter::default())
}
let meta = VirtualBranchesTomlMetadata::from_path(
ctx.project().gb_dir().join("virtual_branches.toml"),
)?;
but_workspace::stacks_v3(&repo, &meta, StacksFilter::default())
}
140 changes: 66 additions & 74 deletions crates/but-api/src/commands/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ pub mod create_reference {
}
}

pub fn create_reference(app: &App, params: create_reference::Params) -> Result<(), Error> {
let project = gitbutler_project::get(params.project_id)?;
let ctx = CommandContext::open(&project, app.app_settings.get()?.clone())?;
pub fn create_reference(
ctx: &CommandContext,
params: create_reference::Params,
) -> Result<(), Error> {
let create_reference::Request { new_name, anchor } = params.request;
let new_ref = Category::LocalBranch
.to_full_name(new_name.as_str())
Expand Down Expand Up @@ -102,56 +103,51 @@ pub fn create_reference(app: &App, params: create_reference::Params) -> Result<(
pub fn create_branch(app: &App, params: CreateBranchParams) -> Result<(), Error> {
let project = gitbutler_project::get(params.project_id)?;
let ctx = CommandContext::open(&project, app.app_settings.get()?.clone())?;
if app.app_settings.get()?.feature_flags.ws3 {
use ReferencePosition::Above;
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
let ws = graph.to_workspace()?;
let stack = ws.try_find_stack_by_id(params.stack_id)?;
let new_ref = Category::LocalBranch
.to_full_name(params.request.name.as_str())
.map_err(anyhow::Error::from)?;
if params.request.preceding_head.is_some() {
return Err(anyhow!(
"BUG: cannot have preceding head name set - let's use the new API instead"
)
.into());
}
use ReferencePosition::Above;
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
let ws = graph.to_workspace()?;
let stack = ws.try_find_stack_by_id(params.stack_id)?;
let new_ref = Category::LocalBranch
.to_full_name(params.request.name.as_str())
.map_err(anyhow::Error::from)?;
if params.request.preceding_head.is_some() {
return Err(anyhow!(
"BUG: cannot have preceding head name set - let's use the new API instead"
)
.into());
}

let mut guard = project.exclusive_worktree_access();
ctx.snapshot_create_dependent_branch(&params.request.name, guard.write_permission())
.ok();
_ = but_workspace::branch::create_reference(
new_ref.as_ref(),
{
let segment = stack.segments.first().context("BUG: no empty stacks")?;
segment
.ref_name
.as_ref()
.map(|rn| ReferenceAnchor::AtSegment {
ref_name: Cow::Borrowed(rn.as_ref()),
let mut guard = project.exclusive_worktree_access();
ctx.snapshot_create_dependent_branch(&params.request.name, guard.write_permission())
.ok();
_ = but_workspace::branch::create_reference(
new_ref.as_ref(),
{
let segment = stack.segments.first().context("BUG: no empty stacks")?;
segment
.ref_name
.as_ref()
.map(|rn| ReferenceAnchor::AtSegment {
ref_name: Cow::Borrowed(rn.as_ref()),
position: Above,
})
.or_else(|| {
Some(ReferenceAnchor::AtCommit {
commit_id: graph.tip_skip_empty(segment.id)?.id,
position: Above,
})
.or_else(|| {
Some(ReferenceAnchor::AtCommit {
commit_id: graph.tip_skip_empty(segment.id)?.id,
position: Above,
})
})
.with_context(|| {
format!(
"TODO: UI should migrate to new version of `create_branch()` instead,\
})
.with_context(|| {
format!(
"TODO: UI should migrate to new version of `create_branch()` instead,\
couldn't handle {params:?}"
)
})?
},
&repo,
&ws,
&mut meta,
)?;
} else {
// NOTE: locking is built-in here.
gitbutler_branch_actions::stack::create_branch(&ctx, params.stack_id, params.request)?;
}
)
})?
},
&repo,
&ws,
&mut meta,
)?;
Ok(())
}

Expand All @@ -166,31 +162,27 @@ pub struct RemoveBranchParams {
pub fn remove_branch(app: &App, params: RemoveBranchParams) -> Result<(), Error> {
let project = gitbutler_project::get(params.project_id)?;
let ctx = CommandContext::open(&project, app.app_settings.get()?.clone())?;
if app.app_settings.get()?.feature_flags.ws3 {
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
let ws = graph.to_workspace()?;
let ref_name = Category::LocalBranch
.to_full_name(params.branch_name.as_str())
.map_err(anyhow::Error::from)?;
let mut guard = project.exclusive_worktree_access();
ctx.snapshot_remove_dependent_branch(&params.branch_name, guard.write_permission())
.ok();
but_workspace::branch::remove_reference(
ref_name.as_ref(),
&repo,
&ws,
&mut meta,
but_workspace::branch::remove_reference::Options {
avoid_anonymous_stacks: true,
// The UI kind of keeps it, but we can't do that somehow
// the object id is null, and stuff breaks. Fine for now.
// Delete is delete.
keep_metadata: false,
},
)?;
} else {
gitbutler_branch_actions::stack::remove_branch(&ctx, params.stack_id, params.branch_name)?;
}
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
let ws = graph.to_workspace()?;
let ref_name = Category::LocalBranch
.to_full_name(params.branch_name.as_str())
.map_err(anyhow::Error::from)?;
let mut guard = project.exclusive_worktree_access();
ctx.snapshot_remove_dependent_branch(&params.branch_name, guard.write_permission())
.ok();
but_workspace::branch::remove_reference(
ref_name.as_ref(),
&repo,
&ws,
&mut meta,
but_workspace::branch::remove_reference::Options {
avoid_anonymous_stacks: true,
// The UI kind of keeps it, but we can't do that somehow
// the object id is null, and stuff breaks. Fine for now.
// Delete is delete.
keep_metadata: false,
},
)?;
Ok(())
}

Expand Down
9 changes: 1 addition & 8 deletions crates/but-api/src/commands/virtual_branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ pub fn create_virtual_branch(
params: CreateVirtualBranchParams,
) -> Result<StackEntryNoOpt, Error> {
let project = gitbutler_project::get(params.project_id)?;
let ws3_enabled = app.app_settings.get()?.feature_flags.ws3;
let ctx = CommandContext::open(&project, app.app_settings.get()?.clone())?;
let stack_entry = if ws3_enabled {
let stack_entry = {
let (repo, mut meta, graph) = ctx.graph_and_meta_and_repo()?;
let ws = graph.to_workspace()?;
let new_ref = Category::LocalBranch
Expand Down Expand Up @@ -73,12 +72,6 @@ pub fn create_virtual_branch(
tip,
order: Some(stack_idx),
}
} else {
gitbutler_branch_actions::create_virtual_branch(
&ctx,
&params.branch,
ctx.project().exclusive_worktree_access().write_permission(),
)?
};
Ok(stack_entry)
}
Expand Down
Loading
Loading