Skip to content

Commit b68ddec

Browse files
committed
Remove redundant git_head endpoint
1 parent c4066ab commit b68ddec

File tree

8 files changed

+6
-53
lines changed

8 files changed

+6
-53
lines changed

apps/desktop/cypress/e2e/support/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getBaseBranchData, getRemoteBranches } from './mock/baseBranch';
22
import { MOCK_BRANCH_LISTINGS } from './mock/branches';
33
import { MOCK_TREE_CHANGES, MOCK_UNIFIED_DIFF } from './mock/changes';
4-
import { MOCK_GIT_HEAD, MOCK_OPEN_WORKSPACE_MODE } from './mock/mode';
4+
import { MOCK_OPEN_WORKSPACE_MODE } from './mock/mode';
55
import { getProject, isGetProjectArgs, listProjects } from './mock/projects';
66
import { getSecret, isGetSecretArgs } from './mock/secrets';
77
import { MOCK_APP_SETTINGS } from './mock/settings';
@@ -134,8 +134,6 @@ Cypress.on('window:before:load', (win) => {
134134
return await Promise.resolve();
135135
case 'canned_branch_name':
136136
return await Promise.resolve('canned-branch-name');
137-
case 'git_head':
138-
return MOCK_GIT_HEAD;
139137
case 'get_base_branch_data':
140138
return getBaseBranchData();
141139
case 'git_remote_branches':
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export const MOCK_GIT_HEAD = '1234123';
2-
31
export const MOCK_OPEN_WORKSPACE_MODE = {
42
type: 'OpenWorkspace'
53
};

apps/desktop/src/lib/mode/modeService.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ export class ModeService {
7272
get mode() {
7373
return this.api.endpoints.mode.useQuery;
7474
}
75-
76-
get head() {
77-
return this.api.endpoints.mode.useQuery;
78-
}
7975
}
8076

8177
function injectEndpoints(api: ClientState['backendApi']) {
@@ -158,25 +154,6 @@ function injectEndpoints(api: ClientState['backendApi']) {
158154
await lifecycleApi.cacheEntryRemoved;
159155
unsubscribe();
160156
}
161-
}),
162-
head: build.query<string, { projectId: string }>({
163-
extraOptions: { command: 'git_head' },
164-
query: (args) => args,
165-
providesTags: [providesList(ReduxTag.HeadMetadata)],
166-
async onCacheEntryAdded(arg, lifecycleApi) {
167-
if (!hasBackendExtra(lifecycleApi.extra)) {
168-
throw new Error('Redux dependency Backend not found!');
169-
}
170-
await lifecycleApi.cacheDataLoaded;
171-
const unsubscribe = lifecycleApi.extra.backend.listen<HeadAndMode>(
172-
`project://${arg.projectId}/git/head`,
173-
(event) => {
174-
lifecycleApi.updateCachedData(() => event.payload.head);
175-
}
176-
);
177-
await lifecycleApi.cacheEntryRemoved;
178-
unsubscribe();
179-
}
180157
})
181158
})
182159
});

apps/desktop/src/routes/[projectId]/+layout.svelte

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@
8686
const stackService = inject(STACK_SERVICE);
8787
const worktreeService = inject(WORKTREE_SERVICE);
8888
89-
const mode = $derived(modeService.mode({ projectId }));
90-
const headQuery = $derived(modeService.head({ projectId }));
91-
const head = $derived(headQuery.response);
89+
const modeQuery = $derived(modeService.mode({ projectId }));
90+
const mode = $derived(modeQuery.response);
9291
9392
// Invalidate stacks when switching branches outside workspace
9493
$effect(() => {
95-
if (head?.type === 'OutsideWorkspace' && head.subject.branchName) {
94+
if (mode?.type === 'OutsideWorkspace' && mode.subject.branchName) {
9695
stackService.invalidateStacks();
9796
}
9897
});
@@ -231,7 +230,7 @@
231230
232231
// Refresh when branch data changes
233232
$effect(() => {
234-
if (baseBranch || headQuery.response) debouncedRemoteBranchRefresh();
233+
if (baseBranch || modeQuery.response) debouncedRemoteBranchRefresh();
235234
});
236235
237236
// Auto-fetch setup
@@ -326,7 +325,7 @@
326325
<ProjectSettingsMenuAction {projectId} />
327326
<FileMenuAction />
328327

329-
<ReduxResult {projectId} result={combineResults(baseBranchQuery.result, mode.result)}>
328+
<ReduxResult {projectId} result={combineResults(baseBranchQuery.result, modeQuery.result)}>
330329
{#snippet children([baseBranch, mode], { projectId })}
331330
{#if !baseBranch}
332331
<NoBaseBranch {projectId} />

crates/but-api/src/commands/git.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ pub fn git_index_size(project_id: ProjectId) -> Result<usize, Error> {
6767
Ok(size)
6868
}
6969

70-
#[api_cmd]
71-
#[tauri::command(async)]
72-
#[instrument(err(Debug))]
73-
pub fn git_head(project_id: ProjectId) -> Result<String, Error> {
74-
let project = gitbutler_project::get(project_id)?;
75-
let ctx = CommandContext::open(&project, AppSettings::load_from_default_path_creating()?)?;
76-
let head = ctx.repo().head().context("failed to get repository head")?;
77-
Ok(head.name().unwrap().to_string())
78-
}
79-
8070
#[api_cmd]
8171
#[tauri::command(async)]
8272
#[instrument(err(Debug))]

crates/but-server/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ async fn handle_command(
152152
"git_test_push" => git::git_test_push_cmd(request.params),
153153
"git_test_fetch" => git::git_test_fetch_cmd(request.params),
154154
"git_index_size" => git::git_index_size_cmd(request.params),
155-
"git_head" => git::git_head_cmd(request.params),
156155
"delete_all_data" => git::delete_all_data_cmd(request.params),
157156
"git_set_global_config" => git::git_set_global_config_cmd(request.params),
158157
"git_remove_global_config" => git::git_remove_global_config_cmd(request.params),

crates/gitbutler-tauri/src/app.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ impl App {
6868
Ok(size)
6969
}
7070

71-
pub fn git_head(&self, project_id: ProjectId, settings: AppSettings) -> Result<String> {
72-
let project = gitbutler_project::get(project_id)?;
73-
let ctx = CommandContext::open(&project, settings)?;
74-
let head = ctx.repo().head().context("failed to get repository head")?;
75-
Ok(head.name().unwrap().to_string())
76-
}
77-
7871
pub fn git_set_global_config(key: &str, value: &str) -> Result<String> {
7972
let mut config = git2::Config::open_default()?;
8073
config.set_str(key, value)?;

crates/gitbutler-tauri/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ fn main() {
207207
.plugin(log.build())
208208
.invoke_handler(tauri::generate_handler![
209209
git::git_remote_branches,
210-
git::git_head,
211210
git::delete_all_data,
212211
git::git_set_global_config,
213212
git::git_remove_global_config,

0 commit comments

Comments
 (0)