mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 11:03:25 +03:00
upgrade to rust 1.45 and fix new clippy warnings
This commit is contained in:
parent
b82d7af173
commit
0dd50b402e
@ -3,7 +3,7 @@
|
||||
#![forbid(unsafe_code)]
|
||||
#![forbid(missing_docs)]
|
||||
#![deny(clippy::all)]
|
||||
#![deny(clippy::result_unwrap_used)]
|
||||
#![deny(clippy::unwrap_used)]
|
||||
#![deny(clippy::panic)]
|
||||
|
||||
pub mod cached;
|
||||
|
@ -219,8 +219,10 @@ fn raw_diff_to_file_diff<'a>(
|
||||
};
|
||||
|
||||
let new_file_diff = if diff.deltas().len() == 1 {
|
||||
// it's safe to unwrap here because we check first that diff.deltas has a single element.
|
||||
let delta: DiffDelta = diff.deltas().next().unwrap();
|
||||
let delta: DiffDelta = diff
|
||||
.deltas()
|
||||
.next()
|
||||
.expect("it's safe to unwrap here because we check first that diff.deltas has a single element");
|
||||
|
||||
if delta.status() == Delta::Untracked {
|
||||
let relative_path =
|
||||
@ -272,7 +274,10 @@ fn raw_diff_to_file_diff<'a>(
|
||||
}
|
||||
|
||||
if !current_lines.is_empty() {
|
||||
adder(¤t_hunk.unwrap(), ¤t_lines);
|
||||
adder(
|
||||
¤t_hunk.expect("invalid hunk"),
|
||||
¤t_lines,
|
||||
);
|
||||
}
|
||||
|
||||
if new_file_diff {
|
||||
|
@ -23,7 +23,8 @@ pub fn stage_hunk(
|
||||
|
||||
let mut opt = ApplyOptions::new();
|
||||
opt.hunk_callback(|hunk| {
|
||||
let header = HunkHeader::from(hunk.unwrap());
|
||||
let header =
|
||||
HunkHeader::from(hunk.expect("hunk unavailable"));
|
||||
hash(&header) == hunk_hash
|
||||
});
|
||||
|
||||
@ -117,7 +118,8 @@ pub fn unstage_hunk(
|
||||
let mut hunk_idx = 0;
|
||||
let mut opt = ApplyOptions::new();
|
||||
opt.hunk_callback(|_hunk| {
|
||||
let res = if hunk_idx == hunk_index.unwrap() {
|
||||
let res = if hunk_idx == hunk_index.expect("invalid hunk")
|
||||
{
|
||||
count += 1;
|
||||
true
|
||||
} else {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![forbid(missing_docs)]
|
||||
#![deny(clippy::result_unwrap_used)]
|
||||
#![deny(clippy::unwrap_used)]
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl FileTreeComponent {
|
||||
if let Some(item) = self.tree.selected_item() {
|
||||
match item.kind {
|
||||
FileTreeItemKind::File(_) => true,
|
||||
_ => false,
|
||||
FileTreeItemKind::Path(..) => false,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
@ -206,7 +206,7 @@ impl FileTreeComponent {
|
||||
StatusItemType::New => '+',
|
||||
StatusItemType::Deleted => '-',
|
||||
StatusItemType::Renamed => 'R',
|
||||
_ => ' ',
|
||||
StatusItemType::Typechange => ' ',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,8 @@ impl FileTreeItems {
|
||||
index: usize,
|
||||
) -> usize {
|
||||
if let Some(parent_path) = Path::new(path).parent() {
|
||||
let parent_path = parent_path.to_str().unwrap();
|
||||
let parent_path =
|
||||
parent_path.to_str().expect("invalid path");
|
||||
for i in (0..=index).rev() {
|
||||
let item = &self.items[i];
|
||||
let item_path = &item.info.full_path;
|
||||
@ -216,18 +217,16 @@ impl FileTreeItems {
|
||||
ancestors.reverse();
|
||||
|
||||
for c in &ancestors {
|
||||
if c.parent().is_some() {
|
||||
let path_string = String::from(c.to_str().unwrap());
|
||||
if !paths_added.contains(c) {
|
||||
paths_added.insert(c);
|
||||
let is_collapsed =
|
||||
collapsed.contains(&path_string);
|
||||
nodes.push(FileTreeItem::new_path(
|
||||
c,
|
||||
path_string,
|
||||
is_collapsed,
|
||||
)?);
|
||||
}
|
||||
if c.parent().is_some() && !paths_added.contains(c) {
|
||||
paths_added.insert(c);
|
||||
let path_string =
|
||||
String::from(c.to_str().expect("invalid path"));
|
||||
let is_collapsed = collapsed.contains(&path_string);
|
||||
nodes.push(FileTreeItem::new_path(
|
||||
c,
|
||||
path_string,
|
||||
is_collapsed,
|
||||
)?);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,8 +332,8 @@ impl StatusTree {
|
||||
inner_collapsed = Some(format!("{}/", &item_path));
|
||||
}
|
||||
|
||||
if prefix.is_none()
|
||||
|| item_path.starts_with(prefix.unwrap())
|
||||
if prefix
|
||||
.map_or(true, |prefix| item_path.starts_with(prefix))
|
||||
{
|
||||
self.tree[i].info.visible = true
|
||||
} else {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#![deny(clippy::cargo)]
|
||||
#![deny(clippy::pedantic)]
|
||||
#![deny(clippy::nursery)]
|
||||
#![deny(clippy::result_unwrap_used)]
|
||||
#![deny(clippy::unwrap_used)]
|
||||
#![deny(clippy::panic)]
|
||||
#![allow(clippy::module_name_repetitions)]
|
||||
#![allow(clippy::multiple_crate_versions)]
|
||||
@ -141,8 +141,8 @@ fn main() -> Result<()> {
|
||||
{
|
||||
app.update_git(ev)?
|
||||
}
|
||||
QueueEvent::GitEvent(..) => (),
|
||||
QueueEvent::SpinnerUpdate => unreachable!(),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
draw(&mut terminal, &app)?;
|
||||
|
@ -137,7 +137,7 @@ impl Status {
|
||||
match self.focus {
|
||||
Focus::WorkDir => self.index_wd.is_file_seleted(),
|
||||
Focus::Stage => self.index.is_file_seleted(),
|
||||
_ => false,
|
||||
Focus::Diff => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ impl Theme {
|
||||
StatusItemType::Renamed => {
|
||||
Style::default().fg(self.diff_file_moved)
|
||||
}
|
||||
_ => Style::default(),
|
||||
StatusItemType::Typechange => Style::default(),
|
||||
};
|
||||
|
||||
self.apply_select(style, selected)
|
||||
@ -155,7 +155,7 @@ impl Theme {
|
||||
DiffLineType::Header => Style::default()
|
||||
.fg(self.disabled_fg)
|
||||
.modifier(Modifier::BOLD),
|
||||
_ => Style::default().fg(if selected {
|
||||
DiffLineType::None => Style::default().fg(if selected {
|
||||
self.command_fg
|
||||
} else {
|
||||
Color::Reset
|
||||
|
Loading…
Reference in New Issue
Block a user