mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
fix more clippy
This commit is contained in:
parent
7df5b9b24a
commit
8e7d2eb4a1
9 changed files with 38 additions and 32 deletions
4
Makefile
4
Makefile
|
|
@ -9,6 +9,10 @@ clippy:
|
|||
cargo clean
|
||||
cargo clippy --all-features
|
||||
|
||||
clippy-pedantic:
|
||||
cargo clean
|
||||
cargo clippy --all-features -- -W clippy::pedantic
|
||||
|
||||
install:
|
||||
cargo install --path "."
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
#![forbid(unsafe_code)]
|
||||
#![forbid(missing_docs)]
|
||||
#![deny(clippy::all)]
|
||||
#![warn(clippy::pedantic)]
|
||||
|
||||
mod diff;
|
||||
mod status;
|
||||
|
|
|
|||
|
|
@ -72,11 +72,7 @@ pub fn get_diff(p: String, stage: bool) -> Diff {
|
|||
let mut opt = DiffOptions::new();
|
||||
opt.pathspec(p);
|
||||
|
||||
let diff = if !stage {
|
||||
opt.include_untracked(true);
|
||||
opt.recurse_untracked_dirs(true);
|
||||
repo.diff_index_to_workdir(None, Some(&mut opt)).unwrap()
|
||||
} else {
|
||||
let diff = if stage {
|
||||
// diff against head
|
||||
let ref_head = repo.head().unwrap();
|
||||
let parent =
|
||||
|
|
@ -88,6 +84,10 @@ pub fn get_diff(p: String, stage: bool) -> Diff {
|
|||
Some(&mut opt),
|
||||
)
|
||||
.unwrap()
|
||||
} else {
|
||||
opt.include_untracked(true);
|
||||
opt.recurse_untracked_dirs(true);
|
||||
repo.diff_index_to_workdir(None, Some(&mut opt)).unwrap()
|
||||
};
|
||||
|
||||
let mut res: Diff = Diff::default();
|
||||
|
|
|
|||
22
src/app.rs
22
src/app.rs
|
|
@ -127,7 +127,11 @@ impl App {
|
|||
self.index.draw(f, left_chunks[1]);
|
||||
self.diff.draw(f, chunks[1]);
|
||||
|
||||
Self::draw_commands(f, chunks_main[2], self.commands());
|
||||
Self::draw_commands(
|
||||
f,
|
||||
chunks_main[2],
|
||||
self.commands().as_slice(),
|
||||
);
|
||||
|
||||
self.commit.draw(f, f.size());
|
||||
self.help.draw(f, f.size());
|
||||
|
|
@ -233,7 +237,13 @@ impl App {
|
|||
let path = i.path;
|
||||
let diff_params = DiffParams(path.clone(), is_stage);
|
||||
|
||||
if self.diff.current() != (path.clone(), is_stage) {
|
||||
if self.diff.current() == (path.clone(), is_stage) {
|
||||
// we are already showing a diff of the right file
|
||||
// maybe the diff changed (outside file change)
|
||||
if let Some(last) = self.git_diff.last() {
|
||||
self.diff.update(path, is_stage, last);
|
||||
}
|
||||
} else {
|
||||
// we dont show the right diff right now, so we need to request
|
||||
if let Some(diff) = self.git_diff.request(diff_params)
|
||||
{
|
||||
|
|
@ -241,12 +251,6 @@ impl App {
|
|||
} else {
|
||||
self.diff.clear();
|
||||
}
|
||||
} else {
|
||||
// we are already showing a diff of the right file
|
||||
// maybe the diff changed (outside file change)
|
||||
if let Some(last) = self.git_diff.last() {
|
||||
self.diff.update(path, is_stage, last);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.diff.clear();
|
||||
|
|
@ -354,7 +358,7 @@ impl App {
|
|||
fn draw_commands<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
cmds: Vec<CommandInfo>,
|
||||
cmds: &[CommandInfo],
|
||||
) {
|
||||
let splitter = Text::Styled(
|
||||
Cow::from(strings::CMD_SPLITTER),
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ pub struct CommitComponent {
|
|||
impl Component for CommitComponent {
|
||||
fn draw<B: Backend>(&self, f: &mut Frame<B>, _rect: Rect) {
|
||||
if self.visible {
|
||||
let txt = if !self.msg.is_empty() {
|
||||
[Text::Raw(Cow::from(self.msg.clone()))]
|
||||
} else {
|
||||
let txt = if self.msg.is_empty() {
|
||||
[Text::Styled(
|
||||
Cow::from(strings::COMMIT_MSG),
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)]
|
||||
} else {
|
||||
[Text::Raw(Cow::from(self.msg.clone()))]
|
||||
};
|
||||
|
||||
ui::Clear::new(
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@ impl DiffComponent {
|
|||
let max = min + height;
|
||||
|
||||
let mut res = Vec::new();
|
||||
let mut line_cursor = 0u16;
|
||||
let mut lines_added = 0u16;
|
||||
let mut line_cursor = 0_u16;
|
||||
let mut lines_added = 0_u16;
|
||||
|
||||
for hunk in self.diff.0.iter() {
|
||||
for hunk in &self.diff.0 {
|
||||
if lines_added >= height {
|
||||
break;
|
||||
}
|
||||
|
|
@ -131,7 +131,12 @@ impl DiffComponent {
|
|||
Color::Reset
|
||||
})
|
||||
.fg(Color::DarkGray);
|
||||
if !end_of_hunk {
|
||||
if end_of_hunk {
|
||||
text.push(Text::Styled(
|
||||
Cow::from(symbols::line::BOTTOM_LEFT),
|
||||
style,
|
||||
));
|
||||
} else {
|
||||
text.push(match line.line_type {
|
||||
DiffLineType::Header => Text::Styled(
|
||||
Cow::from(symbols::line::TOP_LEFT),
|
||||
|
|
@ -142,11 +147,6 @@ impl DiffComponent {
|
|||
style,
|
||||
),
|
||||
});
|
||||
} else {
|
||||
text.push(Text::Styled(
|
||||
Cow::from(symbols::line::BOTTOM_LEFT),
|
||||
style,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ impl IndexComponent {
|
|||
self.items = list.clone();
|
||||
|
||||
let old_selection = self.selection.unwrap_or_default();
|
||||
self.selection = if !self.items.is_empty() {
|
||||
Some(cmp::min(old_selection, self.items.len() - 1))
|
||||
} else {
|
||||
self.selection = if self.items.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(cmp::min(old_selection, self.items.len() - 1))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![deny(clippy::all)]
|
||||
#![warn(clippy::pedantic)]
|
||||
|
||||
mod app;
|
||||
mod components;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ where
|
|||
block: None,
|
||||
items,
|
||||
scroll: 0,
|
||||
style: Default::default(),
|
||||
style: Style::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue