diff --git a/packages/tauri/src/app.rs b/packages/tauri/src/app.rs index 714fecaac..be4d72784 100644 --- a/packages/tauri/src/app.rs +++ b/packages/tauri/src/app.rs @@ -416,13 +416,6 @@ impl App { project_repository.git_match_paths(pattern) } - pub fn git_branches(&self, project_id: &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_branches() - } - pub fn git_remote_branches(&self, project_id: &str) -> Result> { let project = self.gb_project(project_id)?; let project_repository = project_repository::Repository::open(&project) @@ -449,35 +442,6 @@ impl App { Ok(head.name().unwrap().to_string()) } - pub fn git_set_config(&self, project_id: &str, key: &str, value: &str) -> Result { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project) - .context("failed to open project repository")?; - let repo = &project_repository.git_repository; - let mut config = repo.config()?; - config.open_level(git2::ConfigLevel::Local)?; - config.set_str(key, value)?; - Ok(value.to_string()) - } - - pub fn git_get_config(&self, project_id: &str, key: &str) -> Result> { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project)?; - let repo = &project_repository.git_repository; - let config = repo.config()?; - let value = config.get_string(key); - match value { - Ok(value) => Ok(Some(value)), - Err(e) => { - if e.code() == git2::ErrorCode::NotFound { - Ok(None) - } else { - Err(e.into()) - } - } - } - } - pub fn git_set_global_config(&self, key: &str, value: &str) -> Result { let mut config = git2::Config::open_default()?; config.set_str(key, value)?; @@ -499,15 +463,6 @@ impl App { } } - pub fn git_switch_branch(&self, project_id: &str, branch: &git::LocalBranchName) -> Result<()> { - let project = self.gb_project(project_id)?; - let project_repository = project_repository::Repository::open(&project) - .context("failed to open project repository")?; - let gb_repository = self.gb_repository(project_id)?; - gb_repository.flush().context("failed to flush session")?; - project_repository.git_switch_branch(branch) - } - pub fn git_gb_push(&self, project_id: &str) -> Result<()> { let gb_repository = self.gb_repository(project_id)?; gb_repository.push() diff --git a/packages/tauri/src/main.rs b/packages/tauri/src/main.rs index 65146b156..c0c550da6 100644 --- a/packages/tauri/src/main.rs +++ b/packages/tauri/src/main.rs @@ -325,19 +325,6 @@ async fn git_match_paths( Ok(paths) } -#[tauri::command(async)] -#[instrument(skip(handle))] -async fn git_branches( - handle: tauri::AppHandle, - project_id: &str, -) -> Result, Error> { - let app = handle.state::(); - let branches = app - .git_branches(project_id) - .with_context(|| format!("failed to get git branches for project {}", project_id))?; - Ok(branches) -} - #[tauri::command(async)] #[instrument(skip(handle))] async fn git_remote_branches( @@ -421,22 +408,6 @@ async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result Result<(), Error> { - let app = handle.state::(); - let branch_name = format!("refs/heads/{}", branch) - .parse() - .context("invalid branch name")?; - app.git_switch_branch(project_id, &branch_name) - .with_context(|| format!("failed to switch git branch for project {}", project_id))?; - Ok(()) -} - #[tauri::command(async)] #[instrument(skip(handle))] async fn git_stage( @@ -547,31 +518,6 @@ async fn mark_resolved( Ok(()) } -#[tauri::command(async)] -#[instrument(skip(handle))] -async fn git_set_config( - handle: tauri::AppHandle, - project_id: &str, - key: &str, - value: &str, -) -> Result { - let app = handle.state::(); - let result = app.git_set_config(project_id, key, value)?; - Ok(result) -} - -#[tauri::command(async)] -#[instrument(skip(handle))] -async fn git_get_config( - handle: tauri::AppHandle, - project_id: &str, - key: &str, -) -> Result, Error> { - let app = handle.state::(); - let result = app.git_get_config(project_id, key)?; - Ok(result) -} - #[tauri::command(async)] #[instrument(skip(handle))] async fn git_set_global_config( @@ -730,11 +676,9 @@ async fn main() { git_status, git_activity, git_match_paths, - git_branches, git_remote_branches, git_remote_branches_data, git_head, - git_switch_branch, git_commit, git_stage, git_unstage, @@ -760,8 +704,6 @@ async fn main() { virtual_branches::commands::create_virtual_branch_from_branch, fetch_from_target, mark_resolved, - git_set_config, - git_get_config, git_set_global_config, git_get_global_config, keys::commands::get_public_key, diff --git a/packages/tauri/src/project_repository/repository.rs b/packages/tauri/src/project_repository/repository.rs index 587d44e82..d13a68383 100644 --- a/packages/tauri/src/project_repository/repository.rs +++ b/packages/tauri/src/project_repository/repository.rs @@ -214,18 +214,6 @@ impl<'repository> Repository<'repository> { Ok(files) } - pub fn git_branches(&self) -> Result> { - self.git_repository - .branches(Some(git2::BranchType::Local))? - .flatten() - .map(|(branch, _)| branch) - .map(|branch| { - git::LocalBranchName::try_from(&branch) - .context("failed to convert branch to local name") - }) - .collect::>>() - } - pub fn git_remote_branches(&self) -> Result> { self.git_repository .branches(Some(git2::BranchType::Remote))? @@ -324,17 +312,6 @@ impl<'repository> Repository<'repository> { Ok(oids.len().try_into()?) } - pub fn git_switch_branch(&self, branch: &git::LocalBranchName) -> Result<()> { - let branch = self.git_repository.find_branch(&branch.clone().into())?; - self.git_repository - .set_head(branch.name().unwrap()) - .context("failed to set head")?; - self.git_repository - .checkout_head(Some(&mut git2::build::CheckoutBuilder::default().force())) - .context("failed to checkout head")?; - Ok(()) - } - pub fn git_stage_files>(&self, paths: Vec

) -> Result<()> { let mut index = self.git_repository.index()?; for path in paths {