mirror of
https://github.com/gitui-org/gitui.git
synced 2026-10-12 02:14:16 +00:00
nightly clippy fixes
This commit is contained in:
@@ -96,11 +96,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
|
||||
|
||||
/// take out last finished job
|
||||
pub fn take_last(&self) -> Option<J> {
|
||||
if let Ok(mut last) = self.last.lock() {
|
||||
last.take()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.last.lock().map_or(None, |mut last| last.take())
|
||||
}
|
||||
|
||||
/// spawns `task` if nothing is running currently,
|
||||
@@ -164,11 +160,7 @@ impl<J: 'static + AsyncJob> AsyncSingleJob<J> {
|
||||
}
|
||||
|
||||
fn take_next(&self) -> Option<J> {
|
||||
if let Ok(mut next) = self.next.lock() {
|
||||
next.take()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.next.lock().map_or(None, |mut next| next.take())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,12 +131,12 @@ pub fn blame_file(
|
||||
|
||||
return (
|
||||
Some(hunk),
|
||||
line.unwrap_or_else(|_| "".into()),
|
||||
line.unwrap_or_else(|_| String::new()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
(None, line.unwrap_or_else(|_| "".into()))
|
||||
(None, line.unwrap_or_else(|_| String::new()))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
+13
-12
@@ -73,18 +73,19 @@ pub fn extract_username_password(
|
||||
|
||||
/// extract credentials from url
|
||||
pub fn extract_cred_from_url(url: &str) -> BasicAuthCredential {
|
||||
if let Ok(url) = url::Url::parse(url) {
|
||||
BasicAuthCredential::new(
|
||||
if url.username() == "" {
|
||||
None
|
||||
} else {
|
||||
Some(url.username().to_owned())
|
||||
},
|
||||
url.password().map(std::borrow::ToOwned::to_owned),
|
||||
)
|
||||
} else {
|
||||
BasicAuthCredential::new(None, None)
|
||||
}
|
||||
url::Url::parse(url).map_or_else(
|
||||
|_| BasicAuthCredential::new(None, None),
|
||||
|url| {
|
||||
BasicAuthCredential::new(
|
||||
if url.username() == "" {
|
||||
None
|
||||
} else {
|
||||
Some(url.username().to_owned())
|
||||
},
|
||||
url.password().map(std::borrow::ToOwned::to_owned),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -202,16 +202,15 @@ impl Callbacks {
|
||||
}
|
||||
|
||||
match &self.basic_credential {
|
||||
_ if allowed_types.is_ssh_key() => {
|
||||
match username_from_url {
|
||||
Some(username) => {
|
||||
Cred::ssh_key_from_agent(username)
|
||||
}
|
||||
None => Err(GitError::from_str(
|
||||
" Couldn't extract username from url.",
|
||||
)),
|
||||
}
|
||||
}
|
||||
_ if allowed_types.is_ssh_key() => username_from_url
|
||||
.map_or_else(
|
||||
|| {
|
||||
Err(GitError::from_str(
|
||||
" Couldn't extract username from url.",
|
||||
))
|
||||
},
|
||||
Cred::ssh_key_from_agent,
|
||||
),
|
||||
Some(BasicAuthCredential {
|
||||
username: Some(user),
|
||||
password: Some(pwd),
|
||||
|
||||
@@ -13,9 +13,9 @@ pub fn reset_stage(repo_path: &RepoPath, path: &str) -> Result<()> {
|
||||
let obj =
|
||||
repo.find_object(id.into(), Some(ObjectType::Commit))?;
|
||||
|
||||
repo.reset_default(Some(&obj), &[path])?;
|
||||
repo.reset_default(Some(&obj), [path])?;
|
||||
} else {
|
||||
repo.reset_default(None, &[path])?;
|
||||
repo.reset_default(None, [path])?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -75,17 +75,20 @@ pub fn get_tags(repo_path: &RepoPath) -> Result<Tags> {
|
||||
// works on annotated tags lightweight tags `id` already
|
||||
// points to the target commit
|
||||
// see https://github.com/libgit2/libgit2/issues/5586
|
||||
let commit = if let Ok(commit) = repo
|
||||
let commit = repo
|
||||
.find_tag(id)
|
||||
.and_then(|tag| tag.target())
|
||||
.and_then(|target| target.peel_to_commit())
|
||||
{
|
||||
Some(CommitId::new(commit.id()))
|
||||
} else if repo.find_commit(id).is_ok() {
|
||||
Some(CommitId::new(id))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
.map_or_else(
|
||||
|_| {
|
||||
if repo.find_commit(id).is_ok() {
|
||||
Some(CommitId::new(id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
|commit| Some(CommitId::new(commit.id())),
|
||||
);
|
||||
|
||||
let annotation = repo
|
||||
.find_tag(id)
|
||||
|
||||
Reference in New Issue
Block a user