mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-08 19:06:38 +03:00
rm move_files api
This commit is contained in:
parent
0bafe62390
commit
b7c9940eb3
@ -8,7 +8,7 @@ use crate::{
|
||||
bookmarks, database, deltas, events, files, gb_repository,
|
||||
project_repository::{self, activity},
|
||||
projects, pty, reader, search, sessions, storage, users,
|
||||
virtual_branches::{self, branch},
|
||||
virtual_branches,
|
||||
watcher,
|
||||
};
|
||||
|
||||
@ -373,12 +373,19 @@ impl App {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_virtual_branch(
|
||||
pub async fn update_virtual_branch(
|
||||
&self,
|
||||
project_id: &str,
|
||||
branch_update: virtual_branches::branch::BranchUpdateRequest,
|
||||
) -> Result<()> {
|
||||
let gb_repository = self.gb_repository(project_id)?;
|
||||
|
||||
let mut semaphores = self.vbranch_semaphores.lock().await;
|
||||
let semaphore = semaphores
|
||||
.entry(project_id.to_string())
|
||||
.or_insert_with(|| Semaphore::new(1));
|
||||
let _permit = semaphore.acquire().await?;
|
||||
|
||||
virtual_branches::update_branch(&gb_repository, branch_update)?;
|
||||
Ok(())
|
||||
}
|
||||
@ -401,28 +408,6 @@ impl App {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_virtual_branch_files(
|
||||
&self,
|
||||
project_id: &str,
|
||||
branch: &str,
|
||||
paths: Vec<&str>,
|
||||
) -> Result<()> {
|
||||
let gb_repository = self.gb_repository(project_id)?;
|
||||
let paths: Vec<branch::FileOwnership> = paths
|
||||
.into_iter()
|
||||
.map(|p| p.try_into())
|
||||
.collect::<Result<Vec<branch::FileOwnership>, _>>()?;
|
||||
|
||||
let mut semaphores = self.vbranch_semaphores.lock().await;
|
||||
let semaphore = semaphores
|
||||
.entry(project_id.to_string())
|
||||
.or_insert_with(|| Semaphore::new(1));
|
||||
let _permit = semaphore.acquire().await?;
|
||||
|
||||
virtual_branches::move_files(&gb_repository, branch, &paths)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn commit_virtual_branch(
|
||||
&self,
|
||||
project_id: &str,
|
||||
|
@ -605,22 +605,9 @@ async fn update_virtual_branch(
|
||||
branch: virtual_branches::branch::BranchUpdateRequest,
|
||||
) -> Result<(), Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
app.update_virtual_branch(project_id, branch)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[timed(duration(printer = "debug!"))]
|
||||
#[tauri::command(async)]
|
||||
async fn move_virtual_branch_files(
|
||||
handle: tauri::AppHandle,
|
||||
project_id: &str,
|
||||
branch: &str,
|
||||
paths: Vec<&str>,
|
||||
) -> Result<(), Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
app.move_virtual_branch_files(project_id, branch, paths)
|
||||
.await
|
||||
.context("failed to move virtual branch files")?;
|
||||
app.update_virtual_branch(project_id, branch).await.context(
|
||||
"failed to update virtual branch",
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -835,7 +822,6 @@ fn main() {
|
||||
list_bookmarks,
|
||||
list_virtual_branches,
|
||||
create_virtual_branch,
|
||||
move_virtual_branch_files,
|
||||
commit_virtual_branch,
|
||||
get_target_data,
|
||||
set_target_branch,
|
||||
|
@ -16,7 +16,6 @@ export interface VirtualBranchOperations {
|
||||
updateBranchName(branchId: string, name: string): Promise<void | object>;
|
||||
applyBranch(branchId: string): Promise<void | object>;
|
||||
unapplyBranch(branchId: string): Promise<void | object>;
|
||||
moveFiles(branchId: string, paths: Array<string>): Promise<void | object>;
|
||||
updateBranchOwnership(branchId: string, ownership: string): Promise<void | object>;
|
||||
}
|
||||
|
||||
@ -37,7 +36,6 @@ export function getVirtualBranches(
|
||||
updateBranchName: (branchId, name) => updateBranchName(writeable, projectId, branchId, name),
|
||||
applyBranch: (branchId) => applyBranch(writeable, projectId, branchId),
|
||||
unapplyBranch: (branchId) => unapplyBranch(writeable, projectId, branchId),
|
||||
moveFiles: (branchId, paths) => moveFiles(writeable, projectId, branchId, paths),
|
||||
updateBranchOwnership: (branchId, ownership) =>
|
||||
updateBranchOwnership(writeable, projectId, branchId, ownership)
|
||||
};
|
||||
@ -203,25 +201,3 @@ function updateBranchName(
|
||||
error('Unable to update branch!');
|
||||
});
|
||||
}
|
||||
|
||||
function moveFiles(
|
||||
writable: Writable<Loadable<Branch[]>>,
|
||||
projectId: string,
|
||||
|
||||
branchId: string,
|
||||
paths: Array<string>
|
||||
) {
|
||||
return invoke<object>('move_virtual_branch_files', {
|
||||
projectId: projectId,
|
||||
branch: branchId,
|
||||
paths: paths
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
refresh(projectId, writable);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
error('Unable to move files!');
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user