mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 11:03:25 +03:00
fix tons of clippy warnings
This commit is contained in:
parent
b2c44566f6
commit
37da79233a
@ -40,7 +40,7 @@ impl AsyncDiff {
|
||||
pub fn last(&mut self) -> Option<Diff> {
|
||||
let last = self.last.lock().unwrap();
|
||||
if let Some(res) = last.clone() {
|
||||
Some(res.result.clone())
|
||||
Some(res.result)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -90,8 +90,8 @@ impl AsyncDiff {
|
||||
let mut last = arc_last.lock().unwrap();
|
||||
*last = Some(LastResult {
|
||||
result: res,
|
||||
hash: hash,
|
||||
params: params,
|
||||
hash,
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
@ -104,11 +104,7 @@ impl AsyncDiff {
|
||||
}
|
||||
|
||||
fn get_last_param(&self) -> Option<DiffParams> {
|
||||
self.last
|
||||
.lock()
|
||||
.unwrap()
|
||||
.clone()
|
||||
.map_or(None, |e| Some(e.params))
|
||||
self.last.lock().unwrap().clone().map(|e| e.params)
|
||||
}
|
||||
|
||||
fn clear_current(&mut self) {
|
||||
|
@ -24,7 +24,7 @@ pub fn repo() -> Repository {
|
||||
}
|
||||
|
||||
///
|
||||
pub fn commit(msg: &String) {
|
||||
pub fn commit(msg: &str) {
|
||||
scope_time!("commit");
|
||||
|
||||
let repo = repo();
|
||||
@ -41,7 +41,7 @@ pub fn commit(msg: &String) {
|
||||
Some("HEAD"),
|
||||
&signature,
|
||||
&signature,
|
||||
msg.as_str(),
|
||||
msg,
|
||||
&tree,
|
||||
&[&parent],
|
||||
)
|
||||
@ -68,7 +68,7 @@ pub fn stage_add(path: &Path) -> bool {
|
||||
let flags = IndexAddOption::DISABLE_PATHSPEC_MATCH
|
||||
| IndexAddOption::CHECK_PATHSPEC;
|
||||
|
||||
if let Ok(_) = index.add_all(path, flags, cb) {
|
||||
if index.add_all(path, flags, cb).is_ok() {
|
||||
index.write().unwrap();
|
||||
return true;
|
||||
}
|
||||
@ -90,7 +90,7 @@ pub fn stage_reset(path: &Path) -> bool {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
if let Ok(_) = repo.reset_default(Some(&obj), &[path]) {
|
||||
if repo.reset_default(Some(&obj), &[path]).is_ok() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ pub fn index_reset(path: &Path) -> bool {
|
||||
checkout_opts.remove_untracked(true);
|
||||
checkout_opts.path(&path).force();
|
||||
|
||||
if let Ok(_) = repo.checkout_head(Some(&mut checkout_opts)) {
|
||||
if repo.checkout_head(Some(&mut checkout_opts)).is_ok() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
14
src/app.rs
14
src/app.rs
@ -237,7 +237,7 @@ impl App {
|
||||
// we dont show the right diff right now, so we need to request
|
||||
if let Some(diff) = self.git_diff.request(diff_params)
|
||||
{
|
||||
self.diff.update(path.clone(), is_stage, diff);
|
||||
self.diff.update(path, is_stage, diff);
|
||||
} else {
|
||||
self.diff.clear();
|
||||
}
|
||||
@ -245,7 +245,7 @@ impl App {
|
||||
// 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.clone(), is_stage, last);
|
||||
self.diff.update(path, is_stage, last);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -432,13 +432,11 @@ impl App {
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(i) = self.index.selection() {
|
||||
let path = Path::new(i.path.as_str());
|
||||
} else if let Some(i) = self.index.selection() {
|
||||
let path = Path::new(i.path.as_str());
|
||||
|
||||
if sync::stage_reset(path) {
|
||||
self.update();
|
||||
}
|
||||
if sync::stage_reset(path) {
|
||||
self.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ 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.len() > 0 {
|
||||
let txt = if !self.msg.is_empty() {
|
||||
[Text::Raw(Cow::from(self.msg.clone()))]
|
||||
} else {
|
||||
[Text::Styled(
|
||||
@ -73,7 +73,7 @@ impl Component for CommitComponent {
|
||||
self.commit();
|
||||
true
|
||||
}
|
||||
KeyCode::Backspace if self.msg.len() > 0 => {
|
||||
KeyCode::Backspace if !self.msg.is_empty() => {
|
||||
self.msg.pop().unwrap();
|
||||
true
|
||||
}
|
||||
@ -106,6 +106,6 @@ impl CommitComponent {
|
||||
}
|
||||
|
||||
fn can_commit(&self) -> bool {
|
||||
self.msg.len() > 0
|
||||
!self.msg.is_empty()
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ impl DiffComponent {
|
||||
self.scroll =
|
||||
self.scroll.checked_add(1).unwrap_or(self.scroll);
|
||||
} else {
|
||||
self.scroll = self.scroll.checked_sub(1).unwrap_or(0);
|
||||
self.scroll = self.scroll.saturating_sub(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_text(&self, width: u16, height: u16) -> Vec<Text> {
|
||||
let selection = self.scroll;
|
||||
let height_d2 = height / 2;
|
||||
let min = self.scroll.checked_sub(height_d2).unwrap_or(0);
|
||||
let min = self.scroll.saturating_sub(height_d2);
|
||||
let max = min + height;
|
||||
|
||||
let mut res = Vec::new();
|
||||
|
@ -41,7 +41,7 @@ impl IndexComponent {
|
||||
self.items = list.clone();
|
||||
|
||||
let old_selection = self.selection.unwrap_or_default();
|
||||
self.selection = if self.items.len() > 0 {
|
||||
self.selection = if !self.items.is_empty() {
|
||||
Some(cmp::min(old_selection, self.items.len() - 1))
|
||||
} else {
|
||||
None
|
||||
|
@ -59,7 +59,7 @@ pub fn centered_rect_absolute(
|
||||
pub fn draw_list<'b, B: Backend, L>(
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
title: &'b String,
|
||||
title: &'b str,
|
||||
items: L,
|
||||
select: Option<usize>,
|
||||
selected: bool,
|
||||
@ -75,7 +75,7 @@ pub fn draw_list<'b, B: Backend, L>(
|
||||
ScrollableList::new(items)
|
||||
.block(
|
||||
Block::default()
|
||||
.title(title.as_str())
|
||||
.title(title)
|
||||
.borders(Borders::ALL)
|
||||
.title_style(style_title)
|
||||
.border_style(style_border),
|
||||
|
Loading…
Reference in New Issue
Block a user