mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
Fix Clippy Lints (#1390)
* apply latest nigtly clippy lints * temporarily disable const fn lints due to nigh false positive count on nightly
This commit is contained in:
parent
e2a0f3800f
commit
6b5745f6c2
43 changed files with 106 additions and 109 deletions
|
|
@ -207,7 +207,7 @@ mod test {
|
|||
let res =
|
||||
self.v.fetch_add(self.value_to_add, Ordering::SeqCst);
|
||||
|
||||
println!("[job] value: {}", res);
|
||||
println!("[job] value: {res}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -236,8 +236,8 @@ mod test {
|
|||
}
|
||||
|
||||
println!("recv");
|
||||
let _foo = receiver.recv().unwrap();
|
||||
let _foo = receiver.recv().unwrap();
|
||||
receiver.recv().unwrap();
|
||||
receiver.recv().unwrap();
|
||||
assert!(receiver.is_empty());
|
||||
|
||||
assert_eq!(
|
||||
|
|
@ -282,7 +282,7 @@ mod test {
|
|||
wait_for_job(&job);
|
||||
|
||||
println!("recv");
|
||||
let _foo = receiver.recv().unwrap();
|
||||
receiver.recv().unwrap();
|
||||
println!("received");
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -83,12 +83,12 @@ pub type Result<T> = std::result::Result<T, Error>;
|
|||
|
||||
impl<T> From<std::sync::PoisonError<T>> for Error {
|
||||
fn from(error: std::sync::PoisonError<T>) -> Self {
|
||||
Self::Generic(format!("poison error: {}", error))
|
||||
Self::Generic(format!("poison error: {error}"))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<crossbeam_channel::SendError<T>> for Error {
|
||||
fn from(error: crossbeam_channel::SendError<T>) -> Self {
|
||||
Self::Generic(format!("send error: {}", error))
|
||||
Self::Generic(format!("send error: {error}"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,10 +170,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!(matches!(blame_file(repo_path, "foo", None), Err(_)));
|
||||
|
||||
File::create(&root.join(file_path))?
|
||||
.write_all(b"line 1\n")?;
|
||||
|
|
@ -181,7 +178,7 @@ mod tests {
|
|||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "first commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", None)?;
|
||||
let blame = blame_file(repo_path, "foo", None)?;
|
||||
|
||||
assert!(matches!(
|
||||
blame.lines.as_slice(),
|
||||
|
|
@ -205,7 +202,7 @@ mod tests {
|
|||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "second commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", None)?;
|
||||
let blame = blame_file(repo_path, "foo", None)?;
|
||||
|
||||
assert!(matches!(
|
||||
blame.lines.as_slice(),
|
||||
|
|
@ -232,14 +229,14 @@ mod tests {
|
|||
|
||||
file.write(b"line 3\n")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", None)?;
|
||||
let blame = blame_file(repo_path, "foo", None)?;
|
||||
|
||||
assert_eq!(blame.lines.len(), 2);
|
||||
|
||||
stage_add_file(repo_path, file_path)?;
|
||||
commit(repo_path, "third commit")?;
|
||||
|
||||
let blame = blame_file(&repo_path, "foo", None)?;
|
||||
let blame = blame_file(repo_path, "foo", None)?;
|
||||
|
||||
assert_eq!(blame.lines.len(), 3);
|
||||
|
||||
|
|
@ -264,6 +261,6 @@ mod tests {
|
|||
stage_add_file(repo_path, file_path).unwrap();
|
||||
commit(repo_path, "first commit").unwrap();
|
||||
|
||||
assert!(blame_file(&repo_path, "bar\\foo", None).is_ok());
|
||||
assert!(blame_file(repo_path, "bar\\foo", None).is_ok());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ mod test {
|
|||
false,
|
||||
false,
|
||||
None,
|
||||
None.into(),
|
||||
None,
|
||||
)
|
||||
.is_err());
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ mod test {
|
|||
//verify commit msg
|
||||
let details = crate::sync::get_commit_details(
|
||||
&clone2_dir.into(),
|
||||
merge_commit.into(),
|
||||
merge_commit,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ pub(crate) fn branch_set_upstream(
|
|||
|
||||
if branch.upstream().is_err() {
|
||||
let remote = get_default_remote_in_repo(repo)?;
|
||||
let upstream_name = format!("{}/{}", remote, branch_name);
|
||||
let upstream_name = format!("{remote}/{branch_name}");
|
||||
branch.set_upstream(Some(upstream_name.as_str()))?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub fn rename_branch(
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::super::*;
|
||||
use super::super::{checkout_branch, create_branch, RepoPath};
|
||||
use super::rename_branch;
|
||||
use crate::sync::tests::repo_init;
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ mod test {
|
|||
assert_eq!(
|
||||
repo.branches(None)
|
||||
.unwrap()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.0
|
||||
|
|
@ -58,7 +58,7 @@ mod test {
|
|||
assert_eq!(
|
||||
repo.branches(None)
|
||||
.unwrap()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.0
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ mod tests {
|
|||
|
||||
fn count_commits(repo: &Repository, max: usize) -> usize {
|
||||
let mut items = Vec::new();
|
||||
let mut walk = LogWalker::new(&repo, max).unwrap();
|
||||
let mut walk = LogWalker::new(repo, max).unwrap();
|
||||
walk.read(&mut items).unwrap();
|
||||
items.len()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl CommitMessage {
|
|||
///
|
||||
pub fn combine(self) -> String {
|
||||
if let Some(body) = self.body {
|
||||
format!("{}\n{}", self.subject, body)
|
||||
format!("{}\n{body}", self.subject)
|
||||
} else {
|
||||
self.subject
|
||||
}
|
||||
|
|
@ -82,6 +82,8 @@ pub struct CommitDetails {
|
|||
|
||||
impl CommitDetails {
|
||||
///
|
||||
#[allow(clippy::missing_const_for_fn)]
|
||||
// clippy doesn't realise indexing a String is not const
|
||||
pub fn short_hash(&self) -> &str {
|
||||
&self.hash[0..7]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,8 +164,7 @@ mod tests {
|
|||
stage_add_file(repo_path, file_path).unwrap();
|
||||
let c2 = commit(repo_path, "commit2").unwrap();
|
||||
|
||||
let res =
|
||||
get_commits_info(repo_path, &vec![c2, c1], 50).unwrap();
|
||||
let res = get_commits_info(repo_path, &[c2, c1], 50).unwrap();
|
||||
|
||||
assert_eq!(res.len(), 2);
|
||||
assert_eq!(res[0].message.as_str(), "commit2");
|
||||
|
|
@ -187,7 +186,7 @@ mod tests {
|
|||
stage_add_file(repo_path, file_path).unwrap();
|
||||
let c1 = commit(repo_path, "subject\nbody").unwrap();
|
||||
|
||||
let res = get_commits_info(repo_path, &vec![c1], 50).unwrap();
|
||||
let res = get_commits_info(repo_path, &[c1], 50).unwrap();
|
||||
|
||||
assert_eq!(res.len(), 1);
|
||||
assert_eq!(res[0].message.as_str(), "subject");
|
||||
|
|
@ -211,7 +210,7 @@ mod tests {
|
|||
|
||||
let res = get_commits_info(
|
||||
repo_path,
|
||||
&vec![get_head_repo(&repo).unwrap().into()],
|
||||
&[get_head_repo(&repo).unwrap()],
|
||||
50,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl HookPaths {
|
|||
} else {
|
||||
let err = String::from_utf8_lossy(&output.stderr);
|
||||
let out = String::from_utf8_lossy(&output.stdout);
|
||||
let formatted = format!("{}{}", out, err);
|
||||
let formatted = format!("{out}{err}");
|
||||
|
||||
Ok(HookResult::NotOk(formatted))
|
||||
}
|
||||
|
|
@ -324,7 +324,7 @@ exit 1
|
|||
let workdir = TempDir::new().unwrap();
|
||||
let git_root = git_root.into_path();
|
||||
let repo_path = &RepoPath::Workdir {
|
||||
gitdir: dbg!(git_root.to_path_buf()),
|
||||
gitdir: dbg!(git_root),
|
||||
workdir: dbg!(workdir.into_path()),
|
||||
};
|
||||
|
||||
|
|
@ -541,7 +541,7 @@ exit 1
|
|||
let workdir = TempDir::new().unwrap();
|
||||
let git_root = git_root.into_path();
|
||||
let repo_path = &RepoPath::Workdir {
|
||||
gitdir: dbg!(git_root.to_path_buf()),
|
||||
gitdir: dbg!(git_root),
|
||||
workdir: dbg!(workdir.path().to_path_buf()),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ mod tests {
|
|||
walk.read(&mut items).unwrap();
|
||||
|
||||
assert_eq!(items.len(), 1);
|
||||
assert_eq!(items[0], oid2.into());
|
||||
assert_eq!(items[0], oid2);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ mod tests {
|
|||
dbg!(&info);
|
||||
|
||||
assert_eq!(items.len(), 2);
|
||||
assert_eq!(items[0], oid2.into());
|
||||
assert_eq!(items[0], oid2);
|
||||
|
||||
let mut items = Vec::new();
|
||||
walk.read(&mut items).unwrap();
|
||||
|
|
@ -235,7 +235,7 @@ mod tests {
|
|||
walker.read(&mut items).unwrap();
|
||||
|
||||
assert_eq!(items.len(), 1);
|
||||
assert_eq!(items[0], second_commit_id.into());
|
||||
assert_eq!(items[0], second_commit_id);
|
||||
|
||||
let mut items = Vec::new();
|
||||
walker.read(&mut items).unwrap();
|
||||
|
|
|
|||
|
|
@ -125,10 +125,10 @@ mod tests {
|
|||
let temp_dir = TempDir::new().unwrap();
|
||||
let path = temp_dir.path();
|
||||
|
||||
set_search_path(ConfigLevel::System, &path).unwrap();
|
||||
set_search_path(ConfigLevel::Global, &path).unwrap();
|
||||
set_search_path(ConfigLevel::XDG, &path).unwrap();
|
||||
set_search_path(ConfigLevel::ProgramData, &path).unwrap();
|
||||
set_search_path(ConfigLevel::System, path).unwrap();
|
||||
set_search_path(ConfigLevel::Global, path).unwrap();
|
||||
set_search_path(ConfigLevel::XDG, path).unwrap();
|
||||
set_search_path(ConfigLevel::ProgramData, path).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ mod tests {
|
|||
.try_init();
|
||||
}
|
||||
|
||||
/// Same as repo_init, but the repo is a bare repo (--bare)
|
||||
/// Same as `repo_init`, but the repo is a bare repo (--bare)
|
||||
pub fn repo_init_bare() -> Result<(TempDir, Repository)> {
|
||||
init_log();
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ mod tests {
|
|||
///
|
||||
pub fn debug_cmd_print(path: &RepoPath, cmd: &str) {
|
||||
let cmd = debug_cmd(path, cmd);
|
||||
eprintln!("\n----\n{}", cmd);
|
||||
eprintln!("\n----\n{cmd}");
|
||||
}
|
||||
|
||||
/// helper to fetch commmit details using log walker
|
||||
|
|
@ -323,7 +323,7 @@ mod tests {
|
|||
fn debug_cmd(path: &RepoPath, cmd: &str) -> String {
|
||||
let output = if cfg!(target_os = "windows") {
|
||||
Command::new("cmd")
|
||||
.args(&["/C", cmd])
|
||||
.args(["/C", cmd])
|
||||
.current_dir(path.gitpath())
|
||||
.output()
|
||||
.unwrap()
|
||||
|
|
@ -343,12 +343,12 @@ mod tests {
|
|||
if stdout.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("out:\n{}", stdout)
|
||||
format!("out:\n{stdout}")
|
||||
},
|
||||
if stderr.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("err:\n{}", stderr)
|
||||
format!("err:\n{stderr}")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ mod test_conflict_free_rebase {
|
|||
.find_commit(c.into())
|
||||
.unwrap()
|
||||
.parent_ids()
|
||||
.map(|id| CommitId::from(id))
|
||||
.map(CommitId::from)
|
||||
.collect();
|
||||
|
||||
foo
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ mod tests {
|
|||
|
||||
debug_cmd_print(
|
||||
repo_path,
|
||||
&format!("git remote add second {}", remote_path)[..],
|
||||
&format!("git remote add second {remote_path}")[..],
|
||||
);
|
||||
|
||||
let remotes = get_remotes(repo_path).unwrap();
|
||||
|
|
@ -251,7 +251,7 @@ mod tests {
|
|||
|
||||
debug_cmd_print(
|
||||
repo_path,
|
||||
&format!("git remote add origin {}", remote_path)[..],
|
||||
&format!("git remote add origin {remote_path}")[..],
|
||||
);
|
||||
|
||||
//NOTE: aparently remotes are not chronolically sorted but alphabetically
|
||||
|
|
@ -287,7 +287,7 @@ mod tests {
|
|||
|
||||
debug_cmd_print(
|
||||
repo_path,
|
||||
&format!("git remote add someremote {}", remote_path)[..],
|
||||
&format!("git remote add someremote {remote_path}")[..],
|
||||
);
|
||||
|
||||
let remotes = get_remotes(repo_path).unwrap();
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ pub fn push_raw(
|
|||
};
|
||||
|
||||
let branch_name =
|
||||
format!("{}refs/{}/{}", branch_modifier, ref_type, branch);
|
||||
format!("{branch_modifier}refs/{ref_type}/{branch}");
|
||||
remote.push(&[branch_name.as_str()], Some(&mut options))?;
|
||||
|
||||
if let Some((reference, msg)) =
|
||||
|
|
@ -488,11 +488,9 @@ mod tests {
|
|||
upstream_repo
|
||||
.branches(None)
|
||||
.unwrap()
|
||||
.map(|i| i.unwrap())
|
||||
.map(std::result::Result::unwrap)
|
||||
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
|
||||
.filter(|i| i == "test_branch")
|
||||
.next()
|
||||
.is_some(),
|
||||
.any(|i| &i == "test_branch"),
|
||||
true
|
||||
);
|
||||
|
||||
|
|
@ -516,11 +514,9 @@ mod tests {
|
|||
upstream_repo
|
||||
.branches(None)
|
||||
.unwrap()
|
||||
.map(|i| i.unwrap())
|
||||
.map(std::result::Result::unwrap)
|
||||
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
|
||||
.filter(|i| i == "test_branch")
|
||||
.next()
|
||||
.is_some(),
|
||||
.any(|i| &i == "test_branch"),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ pub fn tags_missing_remote(
|
|||
|
||||
let mut local_tags = tags
|
||||
.iter()
|
||||
.filter_map(|tag| tag.map(|tag| format!("refs/tags/{}", tag)))
|
||||
.filter_map(|tag| tag.map(|tag| format!("refs/tags/{tag}")))
|
||||
.collect::<HashSet<_>>();
|
||||
let remote_tags =
|
||||
remote_tag_refs(repo_path, remote, basic_credential)?;
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ c = 4";
|
|||
|
||||
assert_eq!(get_statuses(path), (1, 0));
|
||||
|
||||
stage_add_file(path, &Path::new("test.txt")).unwrap();
|
||||
stage_add_file(path, Path::new("test.txt")).unwrap();
|
||||
|
||||
assert_eq!(get_statuses(path), (0, 1));
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ pub struct Tag {
|
|||
|
||||
impl Tag {
|
||||
///
|
||||
#[allow(clippy::missing_const_for_fn)]
|
||||
// clippy doesn't realise allocating a String is not const
|
||||
pub fn new(name: &str) -> Self {
|
||||
Self {
|
||||
name: name.into(),
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ impl App {
|
|||
|
||||
if let Err(e) = result {
|
||||
let msg =
|
||||
format!("failed to launch editor:\n{}", e);
|
||||
format!("failed to launch editor:\n{e}");
|
||||
log::error!("{}", msg.as_str());
|
||||
self.msg.show_error(msg.as_str())?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ impl BranchListComponent {
|
|||
};
|
||||
|
||||
let span_prefix = Span::styled(
|
||||
format!("{}{} ", is_head_str, upstream_tracking_str),
|
||||
format!("{is_head_str}{upstream_tracking_str} "),
|
||||
theme.commit_author(selected),
|
||||
);
|
||||
let span_hash = Span::styled(
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ impl CommitComponent {
|
|||
|
||||
fn draw_branch_name<B: Backend>(&self, f: &mut Frame<B>) {
|
||||
if let Some(name) = self.git_branch_name.last() {
|
||||
let w = Paragraph::new(format!("{{{}}}", name))
|
||||
let w = Paragraph::new(format!("{{{name}}}"))
|
||||
.alignment(Alignment::Right);
|
||||
|
||||
let rect = {
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ impl CommitList {
|
|||
txt.push(splitter.clone());
|
||||
|
||||
let author_width =
|
||||
(width.saturating_sub(19) / 3).max(3).min(20);
|
||||
(width.saturating_sub(19) / 3).clamp(3, 20);
|
||||
let author = string_width_align(&e.author, author_width);
|
||||
|
||||
// commit author
|
||||
|
|
@ -399,7 +399,7 @@ impl CommitList {
|
|||
|
||||
// commit msg
|
||||
txt.push(Span::styled(
|
||||
format!("{:w$}", &e.msg, w = message_width),
|
||||
format!("{:message_width$}", &e.msg),
|
||||
theme.text(true, selected),
|
||||
));
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ impl CommitList {
|
|||
let branches = self.branches.get(&e.id).map(|names| {
|
||||
names
|
||||
.iter()
|
||||
.map(|name| format!("{{{}}}", name))
|
||||
.map(|name| format!("{{{name}}}"))
|
||||
.join(" ")
|
||||
});
|
||||
|
||||
|
|
@ -502,7 +502,7 @@ impl DrawableComponent for CommitList {
|
|||
));
|
||||
|
||||
let branch_post_fix =
|
||||
self.branch.as_ref().map(|b| format!("- {{{}}}", b));
|
||||
self.branch.as_ref().map(|b| format!("- {{{b}}}"));
|
||||
|
||||
let title = format!(
|
||||
"{} {}/{} {}",
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ impl CreateBranchComponent {
|
|||
Err(e) => {
|
||||
log::error!("create branch: {}", e,);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("create branch error:\n{}", e,),
|
||||
format!("create branch error:\n{e}",),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ impl DiffComponent {
|
|||
|
||||
fn move_selection(&mut self, move_type: ScrollType) {
|
||||
if let Some(diff) = &self.diff {
|
||||
let max = diff.lines.saturating_sub(1) as usize;
|
||||
let max = diff.lines.saturating_sub(1);
|
||||
|
||||
let new_start = match move_type {
|
||||
ScrollType::Down => {
|
||||
|
|
@ -229,7 +229,7 @@ impl DiffComponent {
|
|||
|
||||
fn update_selection(&mut self, new_start: usize) {
|
||||
if let Some(diff) = &self.diff {
|
||||
let max = diff.lines.saturating_sub(1) as usize;
|
||||
let max = diff.lines.saturating_sub(1);
|
||||
let new_start = cmp::min(max, new_start);
|
||||
self.selection = Selection::Single(new_start);
|
||||
self.selected_hunk =
|
||||
|
|
@ -303,9 +303,8 @@ impl DiffComponent {
|
|||
if let Some(diff) = &self.diff {
|
||||
if diff.hunks.is_empty() {
|
||||
let is_positive = diff.size_delta >= 0;
|
||||
let delta_byte_size = ByteSize::b(
|
||||
diff.size_delta.unsigned_abs() as u64,
|
||||
);
|
||||
let delta_byte_size =
|
||||
ByteSize::b(diff.size_delta.unsigned_abs());
|
||||
let sign = if is_positive { "+" } else { "-" };
|
||||
res.extend(vec![Spans::from(vec![
|
||||
Span::raw(Cow::from("size: ")),
|
||||
|
|
@ -378,7 +377,7 @@ impl DiffComponent {
|
|||
.selection
|
||||
.contains(line_cursor),
|
||||
hunk_selected,
|
||||
i == hunk_len as usize - 1,
|
||||
i == hunk_len - 1,
|
||||
&self.theme,
|
||||
));
|
||||
lines_added += 1;
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ impl FileRevlogComponent {
|
|||
let commits = get_commits_info(
|
||||
&self.repo_path.borrow(),
|
||||
&git_log.get_slice(start, SLICE_SIZE)?,
|
||||
self.current_width.get() as usize,
|
||||
self.current_width.get(),
|
||||
);
|
||||
|
||||
if let Ok(commits) = commits {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ impl OptionsPopupComponent {
|
|||
self.theme.text(true, false),
|
||||
),
|
||||
Span::styled(
|
||||
format!("{:^w$}", value, w = half),
|
||||
format!("{value:^half$}"),
|
||||
self.theme.text(true, selected),
|
||||
),
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl PullComponent {
|
|||
self.pending = false;
|
||||
self.hide();
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("fetch failed:\n{}", error),
|
||||
format!("fetch failed:\n{error}"),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ impl PushComponent {
|
|||
if !self.pending {
|
||||
if let Some(err) = self.git_push.last_result()? {
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("push failed:\n{}", err),
|
||||
format!("push failed:\n{err}"),
|
||||
));
|
||||
}
|
||||
self.hide();
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl PushTagsComponent {
|
|||
if !self.pending {
|
||||
if let Some(err) = self.git_push.last_result()? {
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("push tags failed:\n{}", err),
|
||||
format!("push tags failed:\n{err}"),
|
||||
));
|
||||
}
|
||||
self.hide();
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ impl RenameBranchComponent {
|
|||
Err(e) => {
|
||||
log::error!("create branch: {}", e,);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("rename branch error:\n{}", e,),
|
||||
format!("rename branch error:\n{e}",),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ impl StatusTreeComponent {
|
|||
let indent_str = if indent == 0 {
|
||||
String::new()
|
||||
} else {
|
||||
format!("{:w$}", " ", w = (indent as usize) * 2)
|
||||
format!("{:w$}", " ", w = indent * 2)
|
||||
};
|
||||
|
||||
if !visible {
|
||||
|
|
@ -192,7 +192,7 @@ impl StatusTreeComponent {
|
|||
w = width as usize
|
||||
)
|
||||
} else {
|
||||
format!("{} {}{}", status_char, indent_str, file)
|
||||
format!("{status_char} {indent_str}{file}")
|
||||
};
|
||||
|
||||
Some(Span::styled(
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ impl SubmodulesListComponent {
|
|||
);
|
||||
|
||||
let span_name = Span::styled(
|
||||
format!("{:w$} ", module_path, w = name_length),
|
||||
format!("{module_path:name_length$} "),
|
||||
theme.text(true, selected),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ impl TagCommitComponent {
|
|||
|
||||
log::error!("e: {}", e,);
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("tag error:\n{}", e,),
|
||||
format!("tag error:\n{e}",),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ impl TextInputComponent {
|
|||
fn draw_char_count<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
|
||||
let count = self.msg.len();
|
||||
if count > 0 {
|
||||
let w = Paragraph::new(format!("[{} chars]", count))
|
||||
let w = Paragraph::new(format!("[{count} chars]"))
|
||||
.alignment(Alignment::Right);
|
||||
|
||||
let mut rect = {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl LogEntry {
|
|||
} else {
|
||||
format!("{:0>2}m ago", delta.num_minutes())
|
||||
};
|
||||
format!("{: <10}", delta_str)
|
||||
format!("{delta_str: <10}")
|
||||
} else if self.time.date() == now.date() {
|
||||
self.time.format("%T ").to_string()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ pub fn string_width_align(s: &str, width: usize) -> String {
|
|||
if (len >= width_wo_postfix && len <= width)
|
||||
|| (len <= width_wo_postfix)
|
||||
{
|
||||
format!("{:w$}", s, w = width)
|
||||
format!("{s:width$}")
|
||||
} else {
|
||||
let mut s = s.to_string();
|
||||
s.truncate(find_truncate_point(&s, width_wo_postfix));
|
||||
format!("{}{}", s, POSTFIX)
|
||||
format!("{s}{POSTFIX}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ impl StatusTree {
|
|||
*collapsed = true;
|
||||
}
|
||||
|
||||
let path = format!("{}/", path);
|
||||
let path = format!("{path}/");
|
||||
|
||||
for i in index + 1..self.tree.len() {
|
||||
let item = &mut self.tree[i];
|
||||
|
|
@ -373,7 +373,7 @@ impl StatusTree {
|
|||
*collapsed = false;
|
||||
}
|
||||
|
||||
let path = format!("{}/", path);
|
||||
let path = format!("{path}/");
|
||||
|
||||
self.update_visibility(
|
||||
Some(path.as_str()),
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -19,6 +19,8 @@
|
|||
clippy::bool_to_int_with_if,
|
||||
clippy::module_name_repetitions
|
||||
)]
|
||||
#![allow(clippy::missing_const_for_fn)] // high number of false positives on nightly
|
||||
|
||||
//TODO:
|
||||
// #![deny(clippy::expect_used)]
|
||||
|
||||
|
|
@ -121,10 +123,10 @@ fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
let key_config = KeyConfig::init()
|
||||
.map_err(|e| eprintln!("KeyConfig loading error: {}", e))
|
||||
.map_err(|e| eprintln!("KeyConfig loading error: {e}"))
|
||||
.unwrap_or_default();
|
||||
let theme = Theme::init(&cliargs.theme)
|
||||
.map_err(|e| eprintln!("Theme loading error: {}", e))
|
||||
.map_err(|e| eprintln!("Theme loading error: {e}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
setup_terminal()?;
|
||||
|
|
@ -256,13 +258,13 @@ fn shutdown_terminal() {
|
|||
io::stdout().execute(LeaveAlternateScreen).map(|_f| ());
|
||||
|
||||
if let Err(e) = leave_screen {
|
||||
eprintln!("leave_screen failed:\n{}", e);
|
||||
eprintln!("leave_screen failed:\n{e}");
|
||||
}
|
||||
|
||||
let leave_raw_mode = disable_raw_mode();
|
||||
|
||||
if let Err(e) = leave_raw_mode {
|
||||
eprintln!("leave_raw_mode failed:\n{}", e);
|
||||
eprintln!("leave_raw_mode failed:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ pub fn commit_msg(_key_config: &SharedKeyConfig) -> String {
|
|||
"type commit message..".to_string()
|
||||
}
|
||||
pub fn commit_first_line_warning(count: usize) -> String {
|
||||
format!("[subject length: {}]", count)
|
||||
format!("[subject length: {count}]")
|
||||
}
|
||||
pub const fn branch_name_invalid() -> &'static str {
|
||||
"[invalid name]"
|
||||
|
|
@ -157,9 +157,9 @@ pub fn confirm_msg_merge(
|
|||
rebase: bool,
|
||||
) -> String {
|
||||
if rebase {
|
||||
format!("Rebase onto {} incoming commits?", incoming)
|
||||
format!("Rebase onto {incoming} incoming commits?")
|
||||
} else {
|
||||
format!("Merge of {} incoming commits?", incoming)
|
||||
format!("Merge of {incoming} incoming commits?")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ pub fn confirm_msg_delete_branch(
|
|||
_key_config: &SharedKeyConfig,
|
||||
branch_ref: &str,
|
||||
) -> String {
|
||||
format!("Confirm deleting branch: '{}' ?", branch_ref)
|
||||
format!("Confirm deleting branch: '{branch_ref}' ?")
|
||||
}
|
||||
pub fn confirm_title_delete_remote_branch(
|
||||
_key_config: &SharedKeyConfig,
|
||||
|
|
@ -236,7 +236,7 @@ pub fn confirm_msg_delete_remote_branch(
|
|||
_key_config: &SharedKeyConfig,
|
||||
branch_ref: &str,
|
||||
) -> String {
|
||||
format!("Confirm deleting remote branch: '{}' ?", branch_ref)
|
||||
format!("Confirm deleting remote branch: '{branch_ref}' ?")
|
||||
}
|
||||
pub fn confirm_title_delete_tag(
|
||||
_key_config: &SharedKeyConfig,
|
||||
|
|
@ -247,13 +247,13 @@ pub fn confirm_msg_delete_tag(
|
|||
_key_config: &SharedKeyConfig,
|
||||
tag_name: &str,
|
||||
) -> String {
|
||||
format!("Confirm deleting Tag: '{}' ?", tag_name)
|
||||
format!("Confirm deleting Tag: '{tag_name}' ?")
|
||||
}
|
||||
pub fn confirm_title_delete_tag_remote() -> String {
|
||||
"Delete Tag (remote)".to_string()
|
||||
}
|
||||
pub fn confirm_msg_delete_tag_remote(remote_name: &str) -> String {
|
||||
format!("Confirm deleting tag on remote '{}'?", remote_name)
|
||||
format!("Confirm deleting tag on remote '{remote_name}'?")
|
||||
}
|
||||
pub fn confirm_title_force_push(
|
||||
_key_config: &SharedKeyConfig,
|
||||
|
|
@ -292,7 +292,7 @@ pub fn tag_popup_name_msg() -> String {
|
|||
"type tag name".to_string()
|
||||
}
|
||||
pub fn tag_popup_annotation_title(name: &str) -> String {
|
||||
format!("Tag Annotation ({})", name)
|
||||
format!("Tag Annotation ({name})")
|
||||
}
|
||||
pub fn tag_popup_annotation_msg() -> String {
|
||||
"type tag annotation".to_string()
|
||||
|
|
@ -378,7 +378,7 @@ pub mod commit {
|
|||
old: bool,
|
||||
hash: &str,
|
||||
) -> String {
|
||||
format!("{}: {}", if old { "Old" } else { "New" }, hash)
|
||||
format!("{}: {hash}", if old { "Old" } else { "New" })
|
||||
}
|
||||
pub fn details_message_title(
|
||||
_key_config: &SharedKeyConfig,
|
||||
|
|
@ -1065,7 +1065,7 @@ pub mod commands {
|
|||
if marked == 0 {
|
||||
String::default()
|
||||
} else {
|
||||
format!(" {}", marked)
|
||||
format!(" {marked}")
|
||||
},
|
||||
key_config.get_hint(key_config.keys.stash_drop),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ impl StashList {
|
|||
}
|
||||
Err(e) => {
|
||||
self.queue.push(InternalEvent::ShowErrorMsg(
|
||||
format!("stash apply error:\n{}", e,),
|
||||
format!("stash apply error:\n{e}",),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ impl Status {
|
|||
.unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
_ => format!("{:?}", state),
|
||||
_ => format!("{state:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ pub fn centered_rect(
|
|||
|
||||
/// makes sure Rect `r` at least stays as big as min and not bigger than max
|
||||
pub fn rect_inside(min: Size, max: Size, r: Rect) -> Rect {
|
||||
let new_width = r.width.max(min.width).min(max.width);
|
||||
let new_height = r.height.max(min.height).min(max.height);
|
||||
let new_width = r.width.clamp(min.width, max.width);
|
||||
let new_height = r.height.clamp(min.height, max.height);
|
||||
let diff_width = new_width.saturating_sub(r.width);
|
||||
let diff_height = new_height.saturating_sub(r.height);
|
||||
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ mod test {
|
|||
assert_eq!(line_truncator, vec!["", "a"]);
|
||||
}
|
||||
|
||||
/// Tests WordWrapper with words some of which exceed line length and some not.
|
||||
/// Tests `WordWrapper` with words some of which exceed line length and some not.
|
||||
#[test]
|
||||
fn line_composer_word_wrapper_mixed_length() {
|
||||
let width = 20;
|
||||
|
|
@ -471,11 +471,11 @@ mod test {
|
|||
では、";
|
||||
let (word_wrapper, word_wrapper_width) = run_composer(
|
||||
Composer::WordWrapper { trim: true },
|
||||
&text,
|
||||
text,
|
||||
width,
|
||||
);
|
||||
let (line_truncator, _) =
|
||||
run_composer(Composer::LineTruncator, &text, width);
|
||||
run_composer(Composer::LineTruncator, text, width);
|
||||
assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
|
||||
let wrapped = vec![
|
||||
"コンピュータ上で文字",
|
||||
|
|
@ -592,7 +592,7 @@ mod test {
|
|||
);
|
||||
|
||||
// Ensure that if the character was a regular space, it would be wrapped differently.
|
||||
let text_space = text.replace("\u{00a0}", " ");
|
||||
let text_space = text.replace('\u{00a0}', " ");
|
||||
let (word_wrapper_space, _) = run_composer(
|
||||
Composer::WordWrapper { trim: true },
|
||||
&text_space,
|
||||
|
|
|
|||
Loading…
Reference in a new issue