mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-25 07:47:13 +03:00
rust 1.80 clippy fixes
This commit is contained in:
parent
ce923e6fe4
commit
b89672b134
@ -92,7 +92,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
|
||||
}
|
||||
|
||||
/// 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<J: 'static + AsyncJob> AsyncSingleJob<J> {
|
||||
/// 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<J: 'static + AsyncJob> AsyncSingleJob<J> {
|
||||
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<TestJob> =
|
||||
let job: AsyncSingleJob<TestJob> =
|
||||
AsyncSingleJob::new(sender);
|
||||
|
||||
let task = TestJob {
|
||||
@ -265,7 +265,7 @@ mod test {
|
||||
fn test_cancel() {
|
||||
let (sender, receiver) = unbounded();
|
||||
|
||||
let mut job: AsyncSingleJob<TestJob> =
|
||||
let job: AsyncSingleJob<TestJob> =
|
||||
AsyncSingleJob::new(sender);
|
||||
|
||||
let task = TestJob {
|
||||
|
@ -55,9 +55,7 @@ impl AsyncBlame {
|
||||
}
|
||||
|
||||
///
|
||||
pub fn last(
|
||||
&mut self,
|
||||
) -> Result<Option<(BlameParams, FileBlame)>> {
|
||||
pub fn last(&self) -> Result<Option<(BlameParams, FileBlame)>> {
|
||||
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<Option<FileBlame>> {
|
||||
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;
|
||||
|
@ -70,7 +70,7 @@ impl AsyncCommitFiles {
|
||||
|
||||
///
|
||||
pub fn current(
|
||||
&mut self,
|
||||
&self,
|
||||
) -> Result<Option<(CommitFilesParams, ResultType)>> {
|
||||
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(());
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ impl AsyncDiff {
|
||||
}
|
||||
|
||||
///
|
||||
pub fn last(&mut self) -> Result<Option<(DiffParams, FileDiff)>> {
|
||||
pub fn last(&self) -> Result<Option<(DiffParams, FileDiff)>> {
|
||||
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<Option<FileDiff>> {
|
||||
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;
|
||||
|
@ -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()? {
|
||||
|
@ -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()? {
|
||||
|
@ -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()? {
|
||||
|
@ -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<FetchStatus> {
|
||||
pub fn fetch(&self) -> Result<FetchStatus> {
|
||||
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);
|
||||
|
@ -77,7 +77,7 @@ impl AsyncStatus {
|
||||
}
|
||||
|
||||
///
|
||||
pub fn last(&mut self) -> Result<Status> {
|
||||
pub fn last(&self) -> Result<Status> {
|
||||
let last = self.last.lock()?;
|
||||
Ok(last.clone())
|
||||
}
|
||||
@ -89,7 +89,7 @@ impl AsyncStatus {
|
||||
|
||||
///
|
||||
pub fn fetch(
|
||||
&mut self,
|
||||
&self,
|
||||
params: &StatusParams,
|
||||
) -> Result<Option<Status>> {
|
||||
if self.is_pending() {
|
||||
|
@ -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")?;
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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 =
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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 =
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
@ -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),
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -275,10 +275,7 @@ impl FileTree {
|
||||
}
|
||||
}
|
||||
|
||||
fn select_parent(
|
||||
&mut self,
|
||||
current_index: usize,
|
||||
) -> Option<usize> {
|
||||
fn select_parent(&self, current_index: usize) -> Option<usize> {
|
||||
let indent =
|
||||
self.items.tree_items[current_index].info().indent();
|
||||
|
||||
|
@ -76,7 +76,7 @@ impl ChangesComponent {
|
||||
self.files.is_file_selected()
|
||||
}
|
||||
|
||||
fn index_add_remove(&mut self) -> Result<bool> {
|
||||
fn index_add_remove(&self) -> Result<bool> {
|
||||
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(),
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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 => {
|
||||
|
@ -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);
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -451,7 +451,7 @@ impl Status {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_files_changes(&mut self) -> Result<Vec<StatusItem>> {
|
||||
pub fn get_files_changes(&self) -> Result<Vec<StatusItem>> {
|
||||
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(),
|
||||
|
Loading…
Reference in New Issue
Block a user