mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-09 03:18:16 +03:00
fix clippy warnings
This commit is contained in:
parent
4120ea4e56
commit
47fc2924ab
@ -547,7 +547,7 @@ impl Repository {
|
|||||||
// lookup a branch by name
|
// lookup a branch by name
|
||||||
let branch = repo.find_branch(&target_branch, git2::BranchType::Remote)?;
|
let branch = repo.find_branch(&target_branch, git2::BranchType::Remote)?;
|
||||||
|
|
||||||
let remote = repo.branch_remote_name(&branch.get().name().unwrap())?;
|
let remote = repo.branch_remote_name(branch.get().name().unwrap())?;
|
||||||
let remote_url = repo.find_remote(remote.as_str().unwrap())?;
|
let remote_url = repo.find_remote(remote.as_str().unwrap())?;
|
||||||
let remote_url_str = remote_url.url().unwrap();
|
let remote_url_str = remote_url.url().unwrap();
|
||||||
println!("remote: {}", remote_url_str);
|
println!("remote: {}", remote_url_str);
|
||||||
@ -571,7 +571,7 @@ impl Repository {
|
|||||||
// if there are no applied virtual branches, calculate the sha as the merge-base between HEAD in project_repository and this target commit
|
// if there are no applied virtual branches, calculate the sha as the merge-base between HEAD in project_repository and this target commit
|
||||||
let commit = branch.get().peel_to_commit()?;
|
let commit = branch.get().peel_to_commit()?;
|
||||||
let mut commit_oid = commit.id();
|
let mut commit_oid = commit.id();
|
||||||
if active_virtual_branches.len() == 0 {
|
if active_virtual_branches.is_empty() {
|
||||||
// calculate the commit as the merge-base between HEAD in project_repository and this target commit
|
// calculate the commit as the merge-base between HEAD in project_repository and this target commit
|
||||||
let head_oid = repo
|
let head_oid = repo
|
||||||
.head()
|
.head()
|
||||||
@ -599,7 +599,7 @@ impl Repository {
|
|||||||
|
|
||||||
let branch_writer = virtual_branches::branch::Writer::new(self);
|
let branch_writer = virtual_branches::branch::Writer::new(self);
|
||||||
|
|
||||||
if active_virtual_branches.len() == 0 {
|
if active_virtual_branches.is_empty() {
|
||||||
let now = time::UNIX_EPOCH.elapsed().unwrap().as_millis();
|
let now = time::UNIX_EPOCH.elapsed().unwrap().as_millis();
|
||||||
let branch = virtual_branches::branch::Branch {
|
let branch = virtual_branches::branch::Branch {
|
||||||
id: Uuid::new_v4().to_string(),
|
id: Uuid::new_v4().to_string(),
|
||||||
|
@ -618,11 +618,10 @@ async fn move_virtual_branch_files(
|
|||||||
paths: Vec<&str>,
|
paths: Vec<&str>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let target = app
|
app.move_virtual_branch_files(project_id, branch, paths)
|
||||||
.move_virtual_branch_files(project_id, branch, paths)
|
|
||||||
.await
|
.await
|
||||||
.context("failed to move virtual branch files")?;
|
.context("failed to move virtual branch files")?;
|
||||||
Ok(target)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[timed(duration(printer = "debug!"))]
|
#[timed(duration(printer = "debug!"))]
|
||||||
@ -634,8 +633,8 @@ async fn commit_virtual_branch(
|
|||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let target = app.commit_virtual_branch(project_id, branch, message)?;
|
app.commit_virtual_branch(project_id, branch, message)?;
|
||||||
Ok(target)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[timed(duration(printer = "debug!"))]
|
#[timed(duration(printer = "debug!"))]
|
||||||
@ -667,8 +666,8 @@ async fn set_target_branch(
|
|||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
async fn update_branch_target(handle: tauri::AppHandle, project_id: &str) -> Result<(), Error> {
|
async fn update_branch_target(handle: tauri::AppHandle, project_id: &str) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let target = app.update_branch_target(project_id)?;
|
app.update_branch_target(project_id)?;
|
||||||
Ok(target)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[timed(duration(printer = "debug!"))]
|
#[timed(duration(printer = "debug!"))]
|
||||||
@ -679,8 +678,8 @@ async fn apply_branch(
|
|||||||
branch: &str,
|
branch: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let target = app.apply_virtual_branch(project_id, branch)?;
|
app.apply_virtual_branch(project_id, branch)?;
|
||||||
Ok(target)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[timed(duration(printer = "debug!"))]
|
#[timed(duration(printer = "debug!"))]
|
||||||
@ -691,8 +690,8 @@ async fn unapply_branch(
|
|||||||
branch: &str,
|
branch: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let target = app.unapply_virtual_branch(project_id, branch)?;
|
app.unapply_virtual_branch(project_id, branch)?;
|
||||||
Ok(target)
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -60,10 +60,6 @@ impl Hunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&self) -> &usize {
|
|
||||||
&self.start
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contains(&self, line: &usize) -> bool {
|
pub fn contains(&self, line: &usize) -> bool {
|
||||||
self.start <= *line && self.end >= *line
|
self.start <= *line && self.end >= *line
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ pub fn apply_branch(
|
|||||||
|
|
||||||
let branch_tree = gb_repository
|
let branch_tree = gb_repository
|
||||||
.git_repository
|
.git_repository
|
||||||
.find_tree(target_branch.tree.clone())
|
.find_tree(target_branch.tree)
|
||||||
.context("failed to find branch tree")?;
|
.context("failed to find branch tree")?;
|
||||||
|
|
||||||
let merge_options = git2::MergeOptions::new();
|
let merge_options = git2::MergeOptions::new();
|
||||||
@ -410,13 +410,8 @@ pub fn list_virtual_branches(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|(vbranch, _)| vbranch.id == branch.id);
|
.find(|(vbranch, _)| vbranch.id == branch.id);
|
||||||
|
|
||||||
match maybe_status {
|
if let Some((_vbranch, sfiles)) = maybe_status {
|
||||||
Some((_vbranch, sfiles)) => {
|
files = sfiles.clone();
|
||||||
files = sfiles.clone();
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
// this branch has no status, so we just skip it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut vfiles = vec![];
|
let mut vfiles = vec![];
|
||||||
@ -911,7 +906,7 @@ pub fn get_status_by_branch(
|
|||||||
.filter(|b| b.applied)
|
.filter(|b| b.applied)
|
||||||
.any(|b| b.id == default_branch_id)
|
.any(|b| b.id == default_branch_id)
|
||||||
{
|
{
|
||||||
default_branch_id = first_branch_id.clone().unwrap().clone();
|
default_branch_id = first_branch_id.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, distribute hunks to the branches
|
// now, distribute hunks to the branches
|
||||||
@ -1096,7 +1091,7 @@ pub fn update_branch_target(
|
|||||||
|
|
||||||
let vbranches = list_virtual_branches(gb_repository, project_repository)?;
|
let vbranches = list_virtual_branches(gb_repository, project_repository)?;
|
||||||
|
|
||||||
let mut merge_options = git2::MergeOptions::new();
|
let merge_options = git2::MergeOptions::new();
|
||||||
|
|
||||||
// get tree from new target
|
// get tree from new target
|
||||||
let new_target_commit = repo.find_commit(new_target_oid)?;
|
let new_target_commit = repo.find_commit(new_target_oid)?;
|
||||||
@ -1251,7 +1246,7 @@ fn write_tree(
|
|||||||
// if file exists
|
// if file exists
|
||||||
if full_path.exists() {
|
if full_path.exists() {
|
||||||
// add file to index
|
// add file to index
|
||||||
index.add_path(&rel_path).unwrap();
|
index.add_path(rel_path).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1265,13 +1260,12 @@ fn _print_tree(repo: &git2::Repository, tree: &git2::Tree) {
|
|||||||
for entry in tree.iter() {
|
for entry in tree.iter() {
|
||||||
println!("entry: {:?} {:?}", entry.name(), entry.id());
|
println!("entry: {:?} {:?}", entry.name(), entry.id());
|
||||||
// get entry contents
|
// get entry contents
|
||||||
let object = entry.to_object(&repo).unwrap();
|
let object = entry.to_object(repo).unwrap();
|
||||||
let blob = object.as_blob().unwrap();
|
let blob = object.as_blob().unwrap();
|
||||||
// convert content to string
|
// convert content to string
|
||||||
let content = std::str::from_utf8(blob.content()).unwrap();
|
let content = std::str::from_utf8(blob.content()).unwrap();
|
||||||
println!("blob: {:?}", content);
|
println!("blob: {:?}", content);
|
||||||
}
|
}
|
||||||
println!("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn commit(
|
pub fn commit(
|
||||||
@ -2307,7 +2301,7 @@ mod tests {
|
|||||||
// there should be a new vbranch created, but nothing is on it
|
// there should be a new vbranch created, but nothing is on it
|
||||||
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
||||||
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
||||||
assert_eq!(branch.active, false);
|
assert!(!branch.active);
|
||||||
assert_eq!(branch.commits.len(), 1);
|
assert_eq!(branch.commits.len(), 1);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -2475,7 +2469,7 @@ mod tests {
|
|||||||
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
||||||
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
||||||
assert_eq!(branch.files.len(), 1);
|
assert_eq!(branch.files.len(), 1);
|
||||||
assert_eq!(branch.active, true);
|
assert!(branch.active);
|
||||||
|
|
||||||
unapply_branch(&gb_repo, &project_repository, &branch1_id)?;
|
unapply_branch(&gb_repo, &project_repository, &branch1_id)?;
|
||||||
|
|
||||||
@ -2487,7 +2481,7 @@ mod tests {
|
|||||||
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
||||||
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
||||||
assert_eq!(branch.files.len(), 0);
|
assert_eq!(branch.files.len(), 0);
|
||||||
assert_eq!(branch.active, false);
|
assert!(!branch.active);
|
||||||
|
|
||||||
apply_branch(&gb_repo, &project_repository, &branch1_id)?;
|
apply_branch(&gb_repo, &project_repository, &branch1_id)?;
|
||||||
let contents = std::fs::read(std::path::Path::new(&project.path).join(file_path))?;
|
let contents = std::fs::read(std::path::Path::new(&project.path).join(file_path))?;
|
||||||
@ -2501,7 +2495,7 @@ mod tests {
|
|||||||
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
let branches = list_virtual_branches(&gb_repo, &project_repository)?;
|
||||||
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
let branch = &branches.iter().find(|b| b.id == branch1_id).unwrap();
|
||||||
assert_eq!(branch.files.len(), 1);
|
assert_eq!(branch.files.len(), 1);
|
||||||
assert_eq!(branch.active, true);
|
assert!(branch.active);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ pub struct Handler {
|
|||||||
user_store: users::Storage,
|
user_store: users::Storage,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'handler> Handler {
|
impl Handler {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
local_data_dir: path::PathBuf,
|
local_data_dir: path::PathBuf,
|
||||||
project_id: String,
|
project_id: String,
|
||||||
|
Loading…
Reference in New Issue
Block a user