mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-01 22:12:04 +03:00
some docs and fixups
This commit is contained in:
parent
77e07e2308
commit
748630b262
@ -347,10 +347,9 @@ pub async fn reset_files(handle: AppHandle, project_id: &str, files: &str) -> Re
|
|||||||
})?;
|
})?;
|
||||||
// convert files to Vec<String>
|
// convert files to Vec<String>
|
||||||
let files = files
|
let files = files
|
||||||
.split("\n")
|
.split('\n')
|
||||||
.map(|s| s.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
dbg!(files.clone());
|
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.reset_files(&project_id, &files)
|
.reset_files(&project_id, &files)
|
||||||
|
@ -749,8 +749,8 @@ impl ControllerInner {
|
|||||||
) -> Result<(), ControllerError<errors::UnapplyOwnershipError>> {
|
) -> Result<(), ControllerError<errors::UnapplyOwnershipError>> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |_, project_repository, _| {
|
||||||
super::reset_files(gb_repository, project_repository, ownership).map_err(Into::into)
|
super::reset_files(project_repository, ownership).map_err(Into::into)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,12 +565,11 @@ pub fn unapply_ownership(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset a file in the project to the index state
|
||||||
pub fn reset_files(
|
pub fn reset_files(
|
||||||
gb_repository: &gb_repository::Repository,
|
|
||||||
project_repository: &project_repository::Repository,
|
project_repository: &project_repository::Repository,
|
||||||
files: &Vec<String>,
|
files: &Vec<String>,
|
||||||
) -> Result<(), errors::UnapplyOwnershipError> {
|
) -> Result<(), errors::UnapplyOwnershipError> {
|
||||||
dbg!("reset_files");
|
|
||||||
if conflicts::is_resolving(project_repository) {
|
if conflicts::is_resolving(project_repository) {
|
||||||
return Err(errors::UnapplyOwnershipError::Conflict(
|
return Err(errors::UnapplyOwnershipError::Conflict(
|
||||||
errors::ProjectConflictError {
|
errors::ProjectConflictError {
|
||||||
@ -579,32 +578,23 @@ pub fn reset_files(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let repo = &project_repository.git_repository;
|
|
||||||
|
|
||||||
// for each tree, we need to checkout the entry from the index at that path
|
// for each tree, we need to checkout the entry from the index at that path
|
||||||
|
// or if it doesn't exist, remove the file from the working directory
|
||||||
|
let repo = &project_repository.git_repository;
|
||||||
let index = repo.index().context("failed to get index")?;
|
let index = repo.index().context("failed to get index")?;
|
||||||
|
|
||||||
// put together a checkoutbuilder for each file
|
|
||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
let entry = index.get_path(path::Path::new(file), 0);
|
let entry = index.get_path(path::Path::new(file), 0);
|
||||||
match entry {
|
if let Some(entry) = entry {
|
||||||
Some(entry) => {
|
repo.checkout_index_path(path::Path::new(file))
|
||||||
dbg!(&entry);
|
.context("failed to checkout index")?;
|
||||||
repo.checkout_index_path(path::Path::new(file))
|
} else {
|
||||||
.context("failed to checkout index")?;
|
// find the project root
|
||||||
}
|
let project_root = &project_repository.project().path;
|
||||||
None => {
|
let path = path::Path::new(file);
|
||||||
dbg!("new file, just delete it");
|
//combine the project root with the file path
|
||||||
// find the project root
|
let path = &project_root.join(path);
|
||||||
let project_root = &project_repository.project().path;
|
std::fs::remove_file(path).context("failed to remove file")?;
|
||||||
let path = path::Path::new(file);
|
|
||||||
//combine the project root with the file path
|
|
||||||
let path = &project_root.join(path);
|
|
||||||
std::fs::remove_file(&path).context("failed to remove file")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dbg!(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user