diff --git a/asyncgit/src/asyncjob/mod.rs b/asyncgit/src/asyncjob/mod.rs index 3c8564c5..19058f9b 100644 --- a/asyncgit/src/asyncjob/mod.rs +++ b/asyncgit/src/asyncjob/mod.rs @@ -92,7 +92,7 @@ impl AsyncSingleJob { } /// makes sure `next` is cleared and returns `true` if it actually canceled something - pub fn cancel(&mut self) -> bool { + pub fn cancel(&self) -> bool { if let Ok(mut next) = self.next.lock() { if next.is_some() { *next = None; @@ -111,7 +111,7 @@ impl AsyncSingleJob { /// spawns `task` if nothing is running currently, /// otherwise schedules as `next` overwriting if `next` was set before. /// return `true` if the new task gets started right away. - pub fn spawn(&mut self, task: J) -> bool { + pub fn spawn(&self, task: J) -> bool { self.schedule_next(task); self.check_for_job() } @@ -162,7 +162,7 @@ impl AsyncSingleJob { Ok(()) } - fn schedule_next(&mut self, task: J) { + fn schedule_next(&self, task: J) { if let Ok(mut next) = self.next.lock() { *next = Some(task); } @@ -226,7 +226,7 @@ mod test { fn test_overwrite() { let (sender, receiver) = unbounded(); - let mut job: AsyncSingleJob = + let job: AsyncSingleJob = AsyncSingleJob::new(sender); let task = TestJob { @@ -265,7 +265,7 @@ mod test { fn test_cancel() { let (sender, receiver) = unbounded(); - let mut job: AsyncSingleJob = + let job: AsyncSingleJob = AsyncSingleJob::new(sender); let task = TestJob { diff --git a/asyncgit/src/blame.rs b/asyncgit/src/blame.rs index 554b4539..dcbb93af 100644 --- a/asyncgit/src/blame.rs +++ b/asyncgit/src/blame.rs @@ -55,9 +55,7 @@ impl AsyncBlame { } /// - pub fn last( - &mut self, - ) -> Result> { + pub fn last(&self) -> Result> { let last = self.last.lock()?; Ok(last.clone().map(|last_result| { @@ -66,7 +64,7 @@ impl AsyncBlame { } /// - pub fn refresh(&mut self) -> Result<()> { + pub fn refresh(&self) -> Result<()> { if let Ok(Some(param)) = self.get_last_param() { self.clear_current()?; self.request(param)?; @@ -81,7 +79,7 @@ impl AsyncBlame { /// pub fn request( - &mut self, + &self, params: BlameParams, ) -> Result> { log::trace!("request"); @@ -181,7 +179,7 @@ impl AsyncBlame { .map(|last_result| last_result.params)) } - fn clear_current(&mut self) -> Result<()> { + fn clear_current(&self) -> Result<()> { let mut current = self.current.lock()?; current.0 = 0; current.1 = None; diff --git a/asyncgit/src/commit_files.rs b/asyncgit/src/commit_files.rs index fbc5b65e..b2c3da1e 100644 --- a/asyncgit/src/commit_files.rs +++ b/asyncgit/src/commit_files.rs @@ -70,7 +70,7 @@ impl AsyncCommitFiles { /// pub fn current( - &mut self, + &self, ) -> Result> { let c = self.current.lock()?; @@ -84,7 +84,7 @@ impl AsyncCommitFiles { } /// - pub fn fetch(&mut self, params: CommitFilesParams) -> Result<()> { + pub fn fetch(&self, params: CommitFilesParams) -> Result<()> { if self.is_pending() { return Ok(()); } diff --git a/asyncgit/src/diff.rs b/asyncgit/src/diff.rs index 03a04398..5316e67b 100644 --- a/asyncgit/src/diff.rs +++ b/asyncgit/src/diff.rs @@ -73,14 +73,14 @@ impl AsyncDiff { } /// - pub fn last(&mut self) -> Result> { + pub fn last(&self) -> Result> { let last = self.last.lock()?; Ok(last.clone().map(|res| (res.params, res.result))) } /// - pub fn refresh(&mut self) -> Result<()> { + pub fn refresh(&self) -> Result<()> { if let Ok(Some(param)) = self.get_last_param() { self.clear_current()?; self.request(param)?; @@ -95,7 +95,7 @@ impl AsyncDiff { /// pub fn request( - &mut self, + &self, params: DiffParams, ) -> Result> { log::trace!("request {:?}", params); @@ -212,7 +212,7 @@ impl AsyncDiff { Ok(self.last.lock()?.clone().map(|e| e.params)) } - fn clear_current(&mut self) -> Result<()> { + fn clear_current(&self) -> Result<()> { let mut current = self.current.lock()?; current.0 = 0; current.1 = None; diff --git a/asyncgit/src/pull.rs b/asyncgit/src/pull.rs index f23a8aeb..3ba88d60 100644 --- a/asyncgit/src/pull.rs +++ b/asyncgit/src/pull.rs @@ -71,7 +71,7 @@ impl AsyncPull { } /// - pub fn request(&mut self, params: FetchRequest) -> Result<()> { + pub fn request(&self, params: FetchRequest) -> Result<()> { log::trace!("request"); if self.is_pending()? { diff --git a/asyncgit/src/push.rs b/asyncgit/src/push.rs index 78151396..e9696892 100644 --- a/asyncgit/src/push.rs +++ b/asyncgit/src/push.rs @@ -78,7 +78,7 @@ impl AsyncPush { } /// - pub fn request(&mut self, params: PushRequest) -> Result<()> { + pub fn request(&self, params: PushRequest) -> Result<()> { log::trace!("request"); if self.is_pending()? { diff --git a/asyncgit/src/push_tags.rs b/asyncgit/src/push_tags.rs index 3cf9ed92..0984e2ae 100644 --- a/asyncgit/src/push_tags.rs +++ b/asyncgit/src/push_tags.rs @@ -69,7 +69,7 @@ impl AsyncPushTags { } /// - pub fn request(&mut self, params: PushTagsRequest) -> Result<()> { + pub fn request(&self, params: PushTagsRequest) -> Result<()> { log::trace!("request"); if self.is_pending()? { diff --git a/asyncgit/src/revlog.rs b/asyncgit/src/revlog.rs index 6465cf32..5b41d705 100644 --- a/asyncgit/src/revlog.rs +++ b/asyncgit/src/revlog.rs @@ -126,7 +126,7 @@ impl AsyncLog { } /// - pub fn set_background(&mut self) { + pub fn set_background(&self) { self.background.store(true, Ordering::Relaxed); } @@ -146,7 +146,7 @@ impl AsyncLog { } /// - pub fn fetch(&mut self) -> Result { + pub fn fetch(&self) -> Result { self.background.store(false, Ordering::Relaxed); if self.is_pending() { @@ -308,7 +308,7 @@ impl AsyncLog { Ok(()) } - fn clear(&mut self) -> Result<()> { + fn clear(&self) -> Result<()> { self.current.lock()?.commits.clear(); *self.current_head.lock()? = None; self.partial_extract.store(false, Ordering::Relaxed); diff --git a/asyncgit/src/status.rs b/asyncgit/src/status.rs index 491fb104..52f57fb9 100644 --- a/asyncgit/src/status.rs +++ b/asyncgit/src/status.rs @@ -77,7 +77,7 @@ impl AsyncStatus { } /// - pub fn last(&mut self) -> Result { + pub fn last(&self) -> Result { let last = self.last.lock()?; Ok(last.clone()) } @@ -89,7 +89,7 @@ impl AsyncStatus { /// pub fn fetch( - &mut self, + &self, params: &StatusParams, ) -> Result> { if self.is_pending() { diff --git a/asyncgit/src/sync/blame.rs b/asyncgit/src/sync/blame.rs index d3434ed1..19f125f6 100644 --- a/asyncgit/src/sync/blame.rs +++ b/asyncgit/src/sync/blame.rs @@ -167,7 +167,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - assert!(matches!(blame_file(repo_path, "foo", None), Err(_))); + assert!(blame_file(repo_path, "foo", None).is_err()); File::create(root.join(file_path))?.write_all(b"line 1\n")?; diff --git a/asyncgit/src/sync/branch/merge_rebase.rs b/asyncgit/src/sync/branch/merge_rebase.rs index a35784be..3e243c4a 100644 --- a/asyncgit/src/sync/branch/merge_rebase.rs +++ b/asyncgit/src/sync/branch/merge_rebase.rs @@ -79,7 +79,7 @@ mod test { git2::Time::new(0, 0), ); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); push_branch( &clone1_dir.into(), @@ -92,7 +92,7 @@ mod test { ) .unwrap(); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); // clone2 @@ -109,7 +109,7 @@ mod test { git2::Time::new(1, 0), ); - assert_eq!(clone2.head_detached().unwrap(), false); + assert!(!clone2.head_detached().unwrap()); push_branch( &clone2_dir.into(), @@ -122,7 +122,7 @@ mod test { ) .unwrap(); - assert_eq!(clone2.head_detached().unwrap(), false); + assert!(!clone2.head_detached().unwrap()); // clone1 @@ -134,7 +134,7 @@ mod test { git2::Time::new(2, 0), ); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); //lets fetch from origin let bytes = @@ -151,7 +151,7 @@ mod test { // debug_cmd_print(clone1_dir, "git status"); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); merge_upstream_rebase(&clone1_dir.into(), "master").unwrap(); @@ -171,7 +171,7 @@ mod test { ] ); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); } #[test] @@ -270,7 +270,7 @@ mod test { ] ); - assert_eq!(clone1.head_detached().unwrap(), false); + assert!(!clone1.head_detached().unwrap()); } #[test] diff --git a/asyncgit/src/sync/branch/mod.rs b/asyncgit/src/sync/branch/mod.rs index 02645cf5..1a673907 100644 --- a/asyncgit/src/sync/branch/mod.rs +++ b/asyncgit/src/sync/branch/mod.rs @@ -497,7 +497,7 @@ mod tests_branch_compare { let res = branch_compare_upstream(repo_path, "test"); - assert_eq!(res.is_err(), true); + assert!(res.is_err()); } } @@ -730,7 +730,7 @@ mod tests_checkout { let file = root.join(filename); File::create(&file).unwrap(); - stage_add_file(&repo_path, &Path::new(filename)).unwrap(); + stage_add_file(repo_path, Path::new(filename)).unwrap(); assert!(checkout_branch(repo_path, "test").is_ok()); } diff --git a/asyncgit/src/sync/commit.rs b/asyncgit/src/sync/commit.rs index 2b1d78fe..7122c1fe 100644 --- a/asyncgit/src/sync/commit.rs +++ b/asyncgit/src/sync/commit.rs @@ -330,10 +330,7 @@ mod tests { vec![Tag::new("tag")] ); - assert!(matches!( - tag_commit(repo_path, &new_id, "tag", None), - Err(_) - )); + assert!(tag_commit(repo_path, &new_id, "tag", None).is_err()); assert_eq!( get_tags(repo_path).unwrap()[&new_id], @@ -401,13 +398,13 @@ mod tests { let error = commit(repo_path, "commit msg"); - assert!(matches!(error, Err(_))); + assert!(error.is_err()); repo.config()?.set_str("user.email", "email")?; let success = commit(repo_path, "commit msg"); - assert!(matches!(success, Ok(_))); + assert!(success.is_ok()); assert_eq!(count_commits(&repo, 10), 1); let details = @@ -437,7 +434,7 @@ mod tests { let mut success = commit(repo_path, "commit msg"); - assert!(matches!(success, Ok(_))); + assert!(success.is_ok()); assert_eq!(count_commits(&repo, 10), 1); let mut details = @@ -450,7 +447,7 @@ mod tests { success = commit(repo_path, "commit msg"); - assert!(matches!(success, Ok(_))); + assert!(success.is_ok()); assert_eq!(count_commits(&repo, 10), 2); details = diff --git a/asyncgit/src/sync/commit_details.rs b/asyncgit/src/sync/commit_details.rs index cc60a3c6..b70bd52f 100644 --- a/asyncgit/src/sync/commit_details.rs +++ b/asyncgit/src/sync/commit_details.rs @@ -146,14 +146,12 @@ mod tests { let res = get_commit_details(repo_path, id).unwrap(); - assert_eq!( - res.message - .as_ref() - .unwrap() - .subject - .starts_with("test msg"), - true - ); + assert!(res + .message + .as_ref() + .unwrap() + .subject + .starts_with("test msg")); Ok(()) } diff --git a/asyncgit/src/sync/commits_info.rs b/asyncgit/src/sync/commits_info.rs index af8bac0f..f168df1e 100644 --- a/asyncgit/src/sync/commits_info.rs +++ b/asyncgit/src/sync/commits_info.rs @@ -235,7 +235,7 @@ mod tests { assert_eq!(res.len(), 1); dbg!(&res[0].message); - assert_eq!(res[0].message.starts_with("test msg"), true); + assert!(res[0].message.starts_with("test msg")); Ok(()) } diff --git a/asyncgit/src/sync/cred.rs b/asyncgit/src/sync/cred.rs index eb1ef7fc..29f6f0ff 100644 --- a/asyncgit/src/sync/cred.rs +++ b/asyncgit/src/sync/cred.rs @@ -203,38 +203,26 @@ mod tests { #[test] fn test_credential_complete() { - assert_eq!( - BasicAuthCredential::new( - Some("username".to_owned()), - Some("password".to_owned()) - ) - .is_complete(), - true - ); + assert!(BasicAuthCredential::new( + Some("username".to_owned()), + Some("password".to_owned()) + ) + .is_complete()); } #[test] fn test_credential_not_complete() { - assert_eq!( - BasicAuthCredential::new( - None, - Some("password".to_owned()) - ) - .is_complete(), - false - ); - assert_eq!( - BasicAuthCredential::new( - Some("username".to_owned()), - None - ) - .is_complete(), - false - ); - assert_eq!( - BasicAuthCredential::new(None, None).is_complete(), - false - ); + assert!(!BasicAuthCredential::new( + None, + Some("password".to_owned()) + ) + .is_complete()); + assert!(!BasicAuthCredential::new( + Some("username".to_owned()), + None + ) + .is_complete()); + assert!(!BasicAuthCredential::new(None, None).is_complete()); } #[test] @@ -275,7 +263,7 @@ mod tests { repo.remote(DEFAULT_REMOTE_NAME, "http://user@github.com") .unwrap(); - assert_eq!(need_username_password(repo_path).unwrap(), true); + assert!(need_username_password(repo_path).unwrap()); } #[test] @@ -289,7 +277,7 @@ mod tests { repo.remote(DEFAULT_REMOTE_NAME, "git@github.com:user/repo") .unwrap(); - assert_eq!(need_username_password(repo_path).unwrap(), false); + assert!(!need_username_password(repo_path).unwrap()); } #[test] @@ -308,7 +296,7 @@ mod tests { ) .unwrap(); - assert_eq!(need_username_password(repo_path).unwrap(), false); + assert!(!need_username_password(repo_path).unwrap()); } #[test] diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index 60b8735a..d02a00a1 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -557,7 +557,7 @@ mod tests { let res = get_diff(repo_path, "bar.txt", false, None).unwrap(); - assert_eq!(res.hunks.len(), 2) + assert_eq!(res.hunks.len(), 2); } #[test] diff --git a/asyncgit/src/sync/remotes/push.rs b/asyncgit/src/sync/remotes/push.rs index dab50f79..97b1f7fc 100644 --- a/asyncgit/src/sync/remotes/push.rs +++ b/asyncgit/src/sync/remotes/push.rs @@ -254,35 +254,29 @@ mod tests { // Attempt a normal push, // should fail as branches diverged - assert_eq!( - push_branch( - &tmp_other_repo_dir.path().to_str().unwrap().into(), - "origin", - "master", - false, - false, - None, - None, - ) - .is_err(), - true - ); + assert!(push_branch( + &tmp_other_repo_dir.path().to_str().unwrap().into(), + "origin", + "master", + false, + false, + None, + None, + ) + .is_err()); // Attempt force push, // should work as it forces the push through - assert_eq!( - push_branch( - &tmp_other_repo_dir.path().to_str().unwrap().into(), - "origin", - "master", - true, - false, - None, - None, - ) - .is_err(), - false - ); + assert!(!push_branch( + &tmp_other_repo_dir.path().to_str().unwrap().into(), + "origin", + "master", + true, + false, + None, + None, + ) + .is_err()); } #[test] @@ -383,19 +377,16 @@ mod tests { // Attempt a normal push, // should fail as branches diverged - assert_eq!( - push_branch( - &tmp_other_repo_dir.path().to_str().unwrap().into(), - "origin", - "master", - false, - false, - None, - None, - ) - .is_err(), - true - ); + assert!(push_branch( + &tmp_other_repo_dir.path().to_str().unwrap().into(), + "origin", + "master", + false, + false, + None, + None, + ) + .is_err()); // Check that the other commit is not in upstream, // a normal push would not rewrite history @@ -483,40 +474,31 @@ mod tests { .unwrap(); // Test if the branch exits on the remote - assert_eq!( - upstream_repo - .branches(None) - .unwrap() - .map(std::result::Result::unwrap) - .map(|(i, _)| i.name().unwrap().unwrap().to_string()) - .any(|i| &i == "test_branch"), - true - ); + assert!(upstream_repo + .branches(None) + .unwrap() + .map(std::result::Result::unwrap) + .map(|(i, _)| i.name().unwrap().unwrap().to_string()) + .any(|i| &i == "test_branch")); // Delete the remote branch - assert_eq!( - push_branch( - &tmp_repo_dir.path().to_str().unwrap().into(), - "origin", - "test_branch", - false, - true, - None, - None, - ) - .is_ok(), - true - ); + assert!(push_branch( + &tmp_repo_dir.path().to_str().unwrap().into(), + "origin", + "test_branch", + false, + true, + None, + None, + ) + .is_ok()); // Test that the branch has be remove from the remote - assert_eq!( - upstream_repo - .branches(None) - .unwrap() - .map(std::result::Result::unwrap) - .map(|(i, _)| i.name().unwrap().unwrap().to_string()) - .any(|i| &i == "test_branch"), - false - ); + assert!(!upstream_repo + .branches(None) + .unwrap() + .map(std::result::Result::unwrap) + .map(|(i, _)| i.name().unwrap().unwrap().to_string()) + .any(|i| &i == "test_branch")); } } diff --git a/asyncgit/src/sync/reword.rs b/asyncgit/src/sync/reword.rs index c20d252b..8cae0434 100644 --- a/asyncgit/src/sync/reword.rs +++ b/asyncgit/src/sync/reword.rs @@ -177,8 +177,7 @@ mod tests { assert_eq!(message, "commit2"); let reworded = - reword(repo_path, oid2.into(), "NewCommitMessage") - .unwrap(); + reword(repo_path, oid2, "NewCommitMessage").unwrap(); // Need to get the branch again as top oid has changed let branch = diff --git a/asyncgit/src/sync/stash.rs b/asyncgit/src/sync/stash.rs index 009d5f84..c4961681 100644 --- a/asyncgit/src/sync/stash.rs +++ b/asyncgit/src/sync/stash.rs @@ -144,12 +144,9 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - assert_eq!( - stash_save(repo_path, None, true, false).is_ok(), - false - ); + assert!(!stash_save(repo_path, None, true, false).is_ok()); - assert_eq!(get_stashes(repo_path).unwrap().is_empty(), true); + assert!(get_stashes(repo_path).unwrap().is_empty()); } #[test] diff --git a/asyncgit/src/sync/tags.rs b/asyncgit/src/sync/tags.rs index 700c46fd..fe7071db 100644 --- a/asyncgit/src/sync/tags.rs +++ b/asyncgit/src/sync/tags.rs @@ -200,7 +200,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - assert_eq!(get_tags(repo_path).unwrap().is_empty(), true); + assert!(get_tags(repo_path).unwrap().is_empty()); } #[test] diff --git a/asyncgit/src/sync/tree.rs b/asyncgit/src/sync/tree.rs index b63332f2..a6fdfbe5 100644 --- a/asyncgit/src/sync/tree.rs +++ b/asyncgit/src/sync/tree.rs @@ -156,7 +156,7 @@ mod tests { #[test] fn test_sorting() { - let mut list = vec!["file", "folder/file", "folder/afile"] + let mut list = ["file", "folder/file", "folder/afile"] .iter() .map(|f| TreeFile { path: PathBuf::from(f), @@ -181,7 +181,7 @@ mod tests { #[test] fn test_sorting_folders() { - let mut list = vec!["bfolder/file", "afolder/file"] + let mut list = ["bfolder/file", "afolder/file"] .iter() .map(|f| TreeFile { path: PathBuf::from(f), @@ -205,7 +205,7 @@ mod tests { #[test] fn test_sorting_folders2() { - let mut list = vec!["bfolder/sub/file", "afolder/file"] + let mut list = ["bfolder/sub/file", "afolder/file"] .iter() .map(|f| TreeFile { path: PathBuf::from(f), diff --git a/asyncgit/src/sync/utils.rs b/asyncgit/src/sync/utils.rs index 3e313597..83f594df 100644 --- a/asyncgit/src/sync/utils.rs +++ b/asyncgit/src/sync/utils.rs @@ -242,10 +242,7 @@ mod tests { let root = repo.path().parent().unwrap(); let repo_path = root.as_os_str().to_str().unwrap(); - assert_eq!( - stage_add_file(&repo_path.into(), file_path).is_ok(), - false - ); + assert!(!stage_add_file(&repo_path.into(), file_path).is_ok()); } #[test] @@ -391,7 +388,7 @@ mod tests { commit(repo_path, "commit msg").unwrap(); // delete the file now - assert_eq!(remove_file(full_path).is_ok(), true); + assert!(remove_file(full_path).is_ok()); // deleted file in diff now assert_eq!(status_count(StatusType::WorkingDir), 1); @@ -443,7 +440,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - assert_eq!(get_head(repo_path).is_ok(), false); + assert!(!get_head(repo_path).is_ok()); Ok(()) } @@ -455,7 +452,7 @@ mod tests { let repo_path: &RepoPath = &root.as_os_str().to_str().unwrap().into(); - assert_eq!(get_head(repo_path).is_ok(), true); + assert!(get_head(repo_path).is_ok()); Ok(()) } diff --git a/filetreelist/src/filetree.rs b/filetreelist/src/filetree.rs index ddd2e6e6..4b965957 100644 --- a/filetreelist/src/filetree.rs +++ b/filetreelist/src/filetree.rs @@ -275,10 +275,7 @@ impl FileTree { } } - fn select_parent( - &mut self, - current_index: usize, - ) -> Option { + fn select_parent(&self, current_index: usize) -> Option { let indent = self.items.tree_items[current_index].info().indent(); diff --git a/src/components/changes.rs b/src/components/changes.rs index 3ac42b74..7b0bc427 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -76,7 +76,7 @@ impl ChangesComponent { self.files.is_file_selected() } - fn index_add_remove(&mut self) -> Result { + fn index_add_remove(&self) -> Result { if let Some(tree_item) = self.selection() { if self.is_working_dir { if let FileTreeItemKind::File(i) = tree_item.kind { @@ -128,7 +128,7 @@ impl ChangesComponent { Ok(false) } - fn index_add_all(&mut self) -> Result<()> { + fn index_add_all(&self) -> Result<()> { let config = self.options.borrow().status_show_untracked(); sync::stage_add_all(&self.repo.borrow(), "*", config)?; @@ -138,7 +138,7 @@ impl ChangesComponent { Ok(()) } - fn stage_remove_all(&mut self) -> Result<()> { + fn stage_remove_all(&self) -> Result<()> { sync::reset_stage(&self.repo.borrow(), "*")?; self.queue.push(InternalEvent::Update(NeedsUpdate::ALL)); @@ -146,7 +146,7 @@ impl ChangesComponent { Ok(()) } - fn dispatch_reset_workdir(&mut self) -> bool { + fn dispatch_reset_workdir(&self) -> bool { if let Some(tree_item) = self.selection() { self.queue.push(InternalEvent::ConfirmAction( Action::Reset(ResetItem { @@ -159,7 +159,7 @@ impl ChangesComponent { false } - fn add_to_ignore(&mut self) -> bool { + fn add_to_ignore(&self) -> bool { if let Some(tree_item) = self.selection() { if let Err(e) = sync::add_to_ignore( &self.repo.borrow(), diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs index 986a1af2..d5d485c9 100644 --- a/src/components/commit_details/details.rs +++ b/src/components/commit_details/details.rs @@ -244,7 +244,7 @@ impl DetailsComponent { }) } - fn move_scroll_top(&mut self, move_type: ScrollType) -> bool { + fn move_scroll_top(&self, move_type: ScrollType) -> bool { if self.data.is_some() { self.scroll.move_top(move_type) } else { diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 25ab1bb5..82494295 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -171,7 +171,7 @@ impl CommitList { } /// - pub fn checkout(&mut self) { + pub fn checkout(&self) { if let Some(commit_hash) = self.selected_entry().map(|entry| entry.id) { @@ -705,7 +705,7 @@ impl CommitList { } } - fn selection_highlighted(&mut self) -> bool { + fn selection_highlighted(&self) -> bool { let commit = self.commits[self.selection]; self.highlights diff --git a/src/components/diff.rs b/src/components/diff.rs index b7df165d..5318e03a 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -496,7 +496,7 @@ impl DiffComponent { false } - fn unstage_hunk(&mut self) -> Result<()> { + fn unstage_hunk(&self) -> Result<()> { if let Some(diff) = &self.diff { if let Some(hunk) = self.selected_hunk { let hash = diff.hunks[hunk].header_hash; @@ -513,7 +513,7 @@ impl DiffComponent { Ok(()) } - fn stage_hunk(&mut self) -> Result<()> { + fn stage_hunk(&self) -> Result<()> { if let Some(diff) = &self.diff { if let Some(hunk) = self.selected_hunk { if diff.untracked { @@ -621,7 +621,7 @@ impl DiffComponent { ))); } - fn stage_unstage_hunk(&mut self) -> Result<()> { + fn stage_unstage_hunk(&self) -> Result<()> { if self.current.is_stage { self.unstage_hunk()?; } else { diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index d2f5bb8f..4c61179e 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -370,7 +370,7 @@ impl RevisionFilesComponent { Ok(title) } - fn request_files(&mut self, commit: CommitId) { + fn request_files(&self, commit: CommitId) { self.async_treefiles.spawn(AsyncTreeFilesJob::new( self.repo.borrow().clone(), commit, diff --git a/src/input.rs b/src/input.rs index 2e6b04e4..16b17504 100644 --- a/src/input.rs +++ b/src/input.rs @@ -73,7 +73,7 @@ impl Input { } /// - pub fn set_polling(&mut self, enabled: bool) { + pub fn set_polling(&self, enabled: bool) { self.desired_state.set_and_notify(enabled); } diff --git a/src/popups/blame_file.rs b/src/popups/blame_file.rs index 9413b7db..34143481 100644 --- a/src/popups/blame_file.rs +++ b/src/popups/blame_file.rs @@ -685,7 +685,7 @@ impl BlameFilePopup { number_of_digits(max_line_number) } - fn move_selection(&mut self, scroll_type: ScrollType) -> bool { + fn move_selection(&self, scroll_type: ScrollType) -> bool { let mut table_state = self.table_state.take(); let old_selection = table_state.selected().unwrap_or(0); @@ -716,7 +716,7 @@ impl BlameFilePopup { needs_update } - fn set_open_selection(&mut self) { + fn set_open_selection(&self) { if let Some(selection) = self.open_request.as_ref().and_then(|req| req.selection) { diff --git a/src/popups/branchlist.rs b/src/popups/branchlist.rs index c65267fa..0421e5f0 100644 --- a/src/popups/branchlist.rs +++ b/src/popups/branchlist.rs @@ -756,7 +756,7 @@ impl BranchListPopup { Ok(()) } - fn rename_branch(&mut self) { + fn rename_branch(&self) { let cur_branch = &self.branches[self.selection as usize]; self.queue.push(InternalEvent::RenameBranch( cur_branch.reference.clone(), @@ -764,7 +764,7 @@ impl BranchListPopup { )); } - fn delete_branch(&mut self) { + fn delete_branch(&self) { let reference = self.branches[self.selection as usize].reference.clone(); diff --git a/src/popups/options.rs b/src/popups/options.rs index afe5adec..0b06131b 100644 --- a/src/popups/options.rs +++ b/src/popups/options.rs @@ -168,7 +168,7 @@ impl OptionsPopup { } } - fn switch_option(&mut self, right: bool) { + fn switch_option(&self, right: bool) { if right { match self.selection { AppOption::StatusShowUntracked => { diff --git a/src/popups/taglist.rs b/src/popups/taglist.rs index aab6055c..c9e840f7 100644 --- a/src/popups/taglist.rs +++ b/src/popups/taglist.rs @@ -374,7 +374,7 @@ impl TagListPopup { Ok(()) } - pub fn update_missing_remote_tags(&mut self) { + pub fn update_missing_remote_tags(&self) { if self.has_remotes { self.async_remote_tags.spawn(AsyncRemoteTagsJob::new( self.repo.borrow().clone(), @@ -384,7 +384,7 @@ impl TagListPopup { } /// - fn move_selection(&mut self, scroll_type: ScrollType) -> bool { + fn move_selection(&self, scroll_type: ScrollType) -> bool { let mut table_state = self.table_state.take(); let old_selection = table_state.selected().unwrap_or(0); diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index cf4f966b..11415a36 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -257,7 +257,7 @@ impl Revlog { let cancellation_flag = Arc::new(AtomicBool::new(false)); - let mut job = AsyncSingleJob::new(self.sender.clone()); + let job = AsyncSingleJob::new(self.sender.clone()); job.spawn(AsyncCommitFilterJob::new( self.repo.borrow().clone(), self.list.copy_items(), diff --git a/src/tabs/stashing.rs b/src/tabs/stashing.rs index 7afe6ae3..e5564563 100644 --- a/src/tabs/stashing.rs +++ b/src/tabs/stashing.rs @@ -69,7 +69,7 @@ impl Stashing { } /// - pub fn update(&mut self) -> Result<()> { + pub fn update(&self) -> Result<()> { if self.is_visible() { self.git_status //TODO: support options diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index cdaaa2df..c8dceb2f 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -46,7 +46,7 @@ impl StashList { Ok(()) } - fn apply_stash(&mut self) { + fn apply_stash(&self) { if let Some(e) = self.list.selected_entry() { match sync::stash_apply(&self.repo.borrow(), e.id, false) { @@ -62,7 +62,7 @@ impl StashList { } } - fn drop_stash(&mut self) { + fn drop_stash(&self) { if self.list.marked_count() > 0 { self.queue.push(InternalEvent::ConfirmAction( Action::StashDrop(self.list.marked_commits()), @@ -74,7 +74,7 @@ impl StashList { } } - fn pop_stash(&mut self) { + fn pop_stash(&self) { if let Some(e) = self.list.selected_entry() { self.queue.push(InternalEvent::ConfirmAction( Action::StashPop(e.id), @@ -82,7 +82,7 @@ impl StashList { } } - fn inspect(&mut self) { + fn inspect(&self) { if let Some(e) = self.list.selected_entry() { self.queue.push(InternalEvent::OpenPopup( StackablePopupOpen::InspectCommit( diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 4c21eaeb..7d67f3a5 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -451,7 +451,7 @@ impl Status { Ok(()) } - pub fn get_files_changes(&mut self) -> Result> { + pub fn get_files_changes(&self) -> Result> { Ok(self.git_status_stage.last()?.items) } @@ -540,7 +540,7 @@ impl Status { } /// called after confirmation - pub fn reset(&mut self, item: &ResetItem) -> bool { + pub fn reset(&self, item: &ResetItem) -> bool { if let Err(e) = sync::reset_workdir( &self.repo.borrow(), item.path.as_str(),