From 5c98330cc0f8a8a66e5533a3d6f4bd5e0b04d8ef Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Wed, 20 Sep 2023 12:33:03 +0200 Subject: [PATCH] remove old commit page --- packages/tauri/src/app.rs | 29 - packages/tauri/src/main.rs | 42 -- .../src/project_repository/repository.rs | 46 -- packages/ui/src/lib/api/git/index.ts | 12 - .../lib/components/CommandPalette/commands.ts | 15 - packages/ui/src/lib/events.ts | 1 - .../routes/projects/[projectId]/+page.svelte | 14 +- .../[projectId]/QuickCommitModal.svelte | 212 -------- .../projects/[projectId]/commit/+page.svelte | 505 ------------------ .../[projectId]/commit/DiffViewer.svelte | 12 - 10 files changed, 1 insertion(+), 887 deletions(-) delete mode 100644 packages/ui/src/routes/projects/[projectId]/QuickCommitModal.svelte delete mode 100644 packages/ui/src/routes/projects/[projectId]/commit/+page.svelte delete mode 100644 packages/ui/src/routes/projects/[projectId]/commit/DiffViewer.svelte diff --git a/packages/tauri/src/app.rs b/packages/tauri/src/app.rs index e6b1ee8bc..8f739907e 100644 --- a/packages/tauri/src/app.rs +++ b/packages/tauri/src/app.rs @@ -440,35 +440,6 @@ impl App { gb_repository.push() } - pub fn git_stage_files>( - &self, - project_id: &str, - paths: Vec

, - ) -> Result<()> { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project) - .context("failed to open project repository")?; - project_repository.git_stage_files(paths) - } - - pub fn git_unstage_files>( - &self, - project_id: &str, - paths: Vec

, - ) -> Result<()> { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project) - .context("failed to open project repository")?; - project_repository.git_unstage_files(paths) - } - - pub fn git_commit(&self, project_id: &str, message: &str) -> Result<()> { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project) - .context("failed to open project repository")?; - project_repository.git_commit(message) - } - pub fn search(&self, query: &search::Query) -> Result { self.searcher.search(query) } diff --git a/packages/tauri/src/main.rs b/packages/tauri/src/main.rs index 325d936a7..32dc11deb 100644 --- a/packages/tauri/src/main.rs +++ b/packages/tauri/src/main.rs @@ -389,45 +389,6 @@ async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result, -) -> Result<(), Error> { - let app = handle.state::(); - app.git_stage_files(project_id, paths) - .with_context(|| format!("failed to stage file for project {}", project_id))?; - Ok(()) -} - -#[tauri::command(async)] -#[instrument(skip(handle))] -async fn git_unstage( - handle: tauri::AppHandle, - project_id: &str, - paths: Vec<&str>, -) -> Result<(), Error> { - let app = handle.state::(); - app.git_unstage_files(project_id, paths) - .with_context(|| format!("failed to unstage file for project {}", project_id))?; - Ok(()) -} - -#[tauri::command(async)] -#[instrument(skip(handle))] -async fn git_commit( - handle: tauri::AppHandle, - project_id: &str, - message: &str, -) -> Result<(), Error> { - let app = handle.state::(); - app.git_commit(project_id, message) - .with_context(|| format!("failed to commit for project {}", project_id))?; - Ok(()) -} - #[tauri::command(async)] #[instrument(skip(handle))] async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error> { @@ -660,9 +621,6 @@ async fn main() { git_remote_branches, git_remote_branches_data, git_head, - git_commit, - git_stage, - git_unstage, git_wd_diff, delete_all_data, get_logs_archive_path, diff --git a/packages/tauri/src/project_repository/repository.rs b/packages/tauri/src/project_repository/repository.rs index 820210079..3b3dc39c8 100644 --- a/packages/tauri/src/project_repository/repository.rs +++ b/packages/tauri/src/project_repository/repository.rs @@ -328,52 +328,6 @@ impl<'repository> Repository<'repository> { Ok(oids.len().try_into()?) } - pub fn git_stage_files>(&self, paths: Vec

) -> Result<()> { - let mut index = self.git_repository.index()?; - for path in paths { - let path = path.as_ref(); - // to "stage" a file means to: - // - remove it from the index if file is deleted - // - overwrite it in the index otherwise - if !std::path::Path::new(&self.project.path).join(path).exists() { - index.remove_path(path).with_context(|| { - format!("failed to remove path {} from index", path.display()) - })?; - } else { - index - .add_path(path) - .with_context(|| format!("failed to add path {} to index", path.display()))?; - } - } - index.write().with_context(|| "failed to write index")?; - Ok(()) - } - - pub fn git_unstage_files>(&self, paths: Vec

) -> Result<()> { - let head_tree = self.git_repository.head()?.peel_to_tree()?; - let mut head_index = git::Index::new()?; - head_index.read_tree(&head_tree)?; - let mut index = self.git_repository.index()?; - for path in paths { - let path = path.as_ref(); - // to "unstage" a file means to: - // - put head version of the file in the index if it exists - // - remove it from the index otherwise - let head_index_entry = head_index.get_path(path, 0); - if let Some(entry) = head_index_entry { - index - .add(&entry) - .with_context(|| format!("failed to add path {} to index", path.display()))?; - } else { - index.remove_path(path).with_context(|| { - format!("failed to remove path {} from index", path.display()) - })?; - } - } - index.write().with_context(|| "failed to write index")?; - Ok(()) - } - // returns a remote and makes sure that the push url is an ssh url // if url is already ssh, or not set at all, then it returns the remote as is. fn get_remote(&'repository self, name: &str) -> Result> { diff --git a/packages/ui/src/lib/api/git/index.ts b/packages/ui/src/lib/api/git/index.ts index fdb4d05a5..8c12dc7c4 100644 --- a/packages/ui/src/lib/api/git/index.ts +++ b/packages/ui/src/lib/api/git/index.ts @@ -2,18 +2,6 @@ export type { Activity } from './activities'; import { invoke } from '$lib/ipc'; -export function commit(params: { projectId: string; message: string }) { - return invoke('git_commit', params); -} - -export function stage(params: { projectId: string; paths: Array }) { - return invoke('git_stage', params); -} - -export function unstage(params: { projectId: string; paths: Array }) { - return invoke('git_unstage', params); -} - export function matchFiles(params: { projectId: string; matchPattern: string }) { return invoke('git_match_paths', params); } diff --git a/packages/ui/src/lib/components/CommandPalette/commands.ts b/packages/ui/src/lib/components/CommandPalette/commands.ts index 9ac5b9bd8..82a33973d 100644 --- a/packages/ui/src/lib/components/CommandPalette/commands.ts +++ b/packages/ui/src/lib/components/CommandPalette/commands.ts @@ -2,7 +2,6 @@ import type { Project } from '$lib/api/ipc/projects'; import { matchFiles } from '$lib/api/git'; import * as events from '$lib/events'; import { - IconGitCommit, IconFile, IconFeedback, IconSettings, @@ -106,12 +105,6 @@ const commandsGroup = ({ project, input }: { project?: Project; input: string }) : []), ...(project ? [ - { - title: 'Quick commits...', - hotkey: 'C', - action: () => events.emit('openQuickCommitModal'), - icon: IconGitCommit - }, { title: 'Replay', hotkey: 'Meta+R', @@ -138,14 +131,6 @@ const navigateGroup = ({ project, input }: { project?: Project; input: string }) commands: [ ...(project ? [ - { - title: 'Commits', - hotkey: 'Meta+Shift+C', - action: { - href: `/projects/${project.id}/commit/` - }, - icon: IconGitCommit - }, { title: 'Project settings', hotkey: 'Meta+Shift+,', diff --git a/packages/ui/src/lib/events.ts b/packages/ui/src/lib/events.ts index 96db22e2a..e9e9afa78 100644 --- a/packages/ui/src/lib/events.ts +++ b/packages/ui/src/lib/events.ts @@ -5,7 +5,6 @@ type Events = { openCommandPalette: () => void; closeCommandPalette: () => void; openNewProjectModal: () => void; - openQuickCommitModal: () => void; openSendIssueModal: () => void; openBookmarkModal: () => void; createBookmark: (params: { projectId: string }) => void; diff --git a/packages/ui/src/routes/projects/[projectId]/+page.svelte b/packages/ui/src/routes/projects/[projectId]/+page.svelte index 355d0cf2a..d5f583705 100644 --- a/packages/ui/src/routes/projects/[projectId]/+page.svelte +++ b/packages/ui/src/routes/projects/[projectId]/+page.svelte @@ -4,8 +4,7 @@ import { IconGitBranch } from '$lib/icons'; import { derived } from '@square/svelte-store'; import FileSummaries from './FileSummaries.svelte'; - import { Button, Statuses, Tooltip } from '$lib/components'; - import { goto } from '$app/navigation'; + import { Statuses, Tooltip } from '$lib/components'; import Chat from './Chat.svelte'; export let data: PageData; @@ -44,17 +43,6 @@ - {#await statuses.load()} - - {:then} - - {/await} {#await statuses.load() then} diff --git a/packages/ui/src/routes/projects/[projectId]/QuickCommitModal.svelte b/packages/ui/src/routes/projects/[projectId]/QuickCommitModal.svelte deleted file mode 100644 index 0453810a1..000000000 --- a/packages/ui/src/routes/projects/[projectId]/QuickCommitModal.svelte +++ /dev/null @@ -1,212 +0,0 @@ - - - -