fix nighty and raise msrv

This commit is contained in:
extrawurst 2024-02-19 11:27:34 +01:00 committed by extrawurst
parent e7bc4084da
commit acf4661c1e
38 changed files with 68 additions and 110 deletions

View File

@ -1,2 +1,2 @@
msrv = "1.65.0" msrv = "1.70.0"
cognitive-complexity-threshold = 18 cognitive-complexity-threshold = 18

View File

@ -220,11 +220,11 @@ jobs:
- name: Install Rust - name: Install Rust
uses: dtolnay/rust-toolchain@nightly uses: dtolnay/rust-toolchain@nightly
- name: cargo-udeps - name: build cargo-udeps
run: | run: cargo install --git https://github.com/est31/cargo-udeps --locked
# cargo install --locked cargo-udeps
cargo install --git https://github.com/est31/cargo-udeps --locked - name: run cargo-udeps
cargo +nightly udeps --all-targets run: cargo +nightly udeps --all-targets
log-test: log-test:
name: Changelog Test name: Changelog Test

View File

@ -4,7 +4,7 @@ version = "0.24.3"
authors = ["extrawurst <mail@rusticorn.com>"] authors = ["extrawurst <mail@rusticorn.com>"]
description = "blazing fast terminal-ui for git" description = "blazing fast terminal-ui for git"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.70"
exclude = [".github/*", ".vscode/*", "assets/*"] exclude = [".github/*", ".vscode/*", "assets/*"]
homepage = "https://github.com/extrawurst/gitui" homepage = "https://github.com/extrawurst/gitui"
repository = "https://github.com/extrawurst/gitui" repository = "https://github.com/extrawurst/gitui"

View File

@ -82,6 +82,11 @@ clippy-nightly:
check: fmt clippy test deny check: fmt clippy test deny
check-nightly:
cargo +nightly c
cargo +nightly clippy --workspace --all-features
cargo +nightly t
deny: deny:
cargo deny check cargo deny check

View File

@ -215,7 +215,7 @@ All contain a single binary file
### Requirements ### Requirements
- Minimum supported `rust`/`cargo` version: `1.65` - Minimum supported `rust`/`cargo` version: `1.70`
- See [Install Rust](https://www.rust-lang.org/tools/install) - See [Install Rust](https://www.rust-lang.org/tools/install)
- To build openssl dependency (see https://docs.rs/openssl/latest/openssl/) - To build openssl dependency (see https://docs.rs/openssl/latest/openssl/)

View File

@ -201,7 +201,9 @@ impl AsyncLog {
) -> Result<()> { ) -> Result<()> {
let start_time = Instant::now(); let start_time = Instant::now();
let mut entries = Vec::with_capacity(LIMIT_COUNT); let mut entries = vec![CommitId::default(); LIMIT_COUNT];
entries.resize(0, CommitId::default());
let r = repo(repo_path)?; let r = repo(repo_path)?;
let mut walker = let mut walker =
LogWalker::new(&r, LIMIT_COUNT)?.filter(filter); LogWalker::new(&r, LIMIT_COUNT)?.filter(filter);

View File

@ -69,11 +69,8 @@ pub fn blame_file(
utils::get_head_repo(&repo)? utils::get_head_repo(&repo)?
}; };
let spec = format!( let spec =
"{}:{}", format!("{}:{}", commit_id, fixup_windows_path(file_path));
commit_id.to_string(),
fixup_windows_path(file_path)
);
let object = repo.revparse_single(&spec)?; let object = repo.revparse_single(&spec)?;
let blob = repo.find_blob(object.id())?; let blob = repo.find_blob(object.id())?;

View File

@ -162,10 +162,7 @@ pub(crate) fn get_commit_diff<'a>(
Some(&mut opts), Some(&mut opts),
)?; )?;
if stashes if stashes.is_some_and(|stashes| stashes.contains(&id)) {
.map(|stashes| stashes.contains(&id))
.unwrap_or_default()
{
if let Ok(untracked_commit) = commit.parent_id(2) { if let Ok(untracked_commit) = commit.parent_id(2) {
let untracked_diff = get_commit_diff( let untracked_diff = get_commit_diff(
repo, repo,

View File

@ -115,8 +115,7 @@ impl LogFilterSearch {
.new_file() .new_file()
.path() .path()
.and_then(|file| file.as_os_str().to_str()) .and_then(|file| file.as_os_str().to_str())
.map(|file| self.match_text(file)) .is_some_and(|file| self.match_text(file))
.unwrap_or_default()
{ {
return true; return true;
} }
@ -125,8 +124,7 @@ impl LogFilterSearch {
.old_file() .old_file()
.path() .path()
.and_then(|file| file.as_os_str().to_str()) .and_then(|file| file.as_os_str().to_str())
.map(|file| self.match_text(file)) .is_some_and(|file| self.match_text(file))
.unwrap_or_default()
}) })
} }
@ -194,8 +192,7 @@ pub fn filter_commit_by_search(
.ok() .ok()
}) })
.flatten() .flatten()
.map(|diff| filter.match_diff(&diff)) .is_some_and(|diff| filter.match_diff(&diff));
.unwrap_or_default();
let authors_match = filter let authors_match = filter
.options .options
@ -205,13 +202,11 @@ pub fn filter_commit_by_search(
let name_match = commit let name_match = commit
.author() .author()
.name() .name()
.map(|name| filter.match_text(name)) .is_some_and(|name| filter.match_text(name));
.unwrap_or_default();
let mail_match = commit let mail_match = commit
.author() .author()
.email() .email()
.map(|name| filter.match_text(name)) .is_some_and(|name| filter.match_text(name));
.unwrap_or_default();
name_match || mail_match name_match || mail_match
}) })

View File

@ -1,3 +1,5 @@
use std::fmt::Display;
use super::RepoPath; use super::RepoPath;
use crate::{error::Result, sync::repository::repo}; use crate::{error::Result, sync::repository::repo};
use git2::{Commit, Error, Oid}; use git2::{Commit, Error, Oid};
@ -46,9 +48,12 @@ impl CommitId {
} }
} }
impl ToString for CommitId { impl Display for CommitId {
fn to_string(&self) -> String { fn fmt(
self.0.to_string() &self,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
write!(f, "{}", self.0)
} }
} }

View File

@ -60,9 +60,9 @@ pub(crate) fn get_default_remote_in_repo(
let remotes = repo.remotes()?; let remotes = repo.remotes()?;
// if `origin` exists return that // if `origin` exists return that
let found_origin = remotes.iter().any(|r| { let found_origin = remotes
r.map(|r| r == DEFAULT_REMOTE_NAME).unwrap_or_default() .iter()
}); .any(|r| r.is_some_and(|r| r == DEFAULT_REMOTE_NAME));
if found_origin { if found_origin {
return Ok(DEFAULT_REMOTE_NAME.into()); return Ok(DEFAULT_REMOTE_NAME.into());
} }

View File

@ -9,9 +9,7 @@ use super::{
}; };
use crate::error::Result; use crate::error::Result;
use git2::{DiffLine, DiffLineType, Repository}; use git2::{DiffLine, DiffLineType, Repository};
use std::{ use std::{collections::HashSet, fs::File, io::Read};
collections::HashSet, convert::TryFrom, fs::File, io::Read,
};
const NEWLINE: char = '\n'; const NEWLINE: char = '\n';

View File

@ -136,7 +136,7 @@ impl FileTree {
}; };
let changed_index = let changed_index =
new_index.map(|i| i != selection).unwrap_or_default(); new_index.is_some_and(|i| i != selection);
if changed_index { if changed_index {
self.selection = new_index; self.selection = new_index;
@ -335,8 +335,7 @@ impl FileTree {
self.items self.items
.tree_items .tree_items
.get(index) .get(index)
.map(|item| item.info().is_visible()) .is_some_and(|item| item.info().is_visible())
.unwrap_or_default()
} }
} }

View File

@ -346,8 +346,7 @@ impl FileTreeItems {
if items if items
.get(i + 1) .get(i + 1)
.map(|item| item.kind().is_path()) .is_some_and(|item| item.kind().is_path())
.unwrap_or_default()
{ {
let next_item = items.remove(i + 1); let next_item = items.remove(i + 1);
let item_mut = &mut items[i]; let item_mut = &mut items[i];

View File

@ -1,8 +1,5 @@
use crate::error::Result; use crate::error::Result;
use std::{ use std::path::{Path, PathBuf};
convert::TryFrom,
path::{Path, PathBuf},
};
/// holds the information shared among all `FileTreeItem` in a `FileTree` /// holds the information shared among all `FileTreeItem` in a `FileTree`
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

View File

@ -22,12 +22,7 @@ impl<'a> Iterator for TreeIterator<'a> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.item_iter.next().map(|(index, item)| { self.item_iter.next().map(|(index, item)| {
( (item, self.selection.is_some_and(|i| i == index))
item,
self.selection
.map(|i| i == index)
.unwrap_or_default(),
)
}) })
} }
} }

View File

@ -26,7 +26,6 @@ use ratatui::{
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState}, widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
Frame, Frame,
}; };
use std::convert::TryInto;
static NO_COMMIT_ID: &str = "0000000"; static NO_COMMIT_ID: &str = "0000000";
static NO_AUTHOR: &str = "<no author>"; static NO_AUTHOR: &str = "<no author>";

View File

@ -36,7 +36,7 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs},
Frame, Frame,
}; };
use std::{cell::Cell, convert::TryInto}; use std::cell::Cell;
use ui::style::SharedTheme; use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
@ -505,12 +505,10 @@ impl BranchListComponent {
.iter() .iter()
.enumerate() .enumerate()
.filter(|(index, b)| { .filter(|(index, b)| {
b.local_details() b.local_details().is_some_and(|details| {
.map(|details| {
details.is_head details.is_head
&& *index == self.selection as usize && *index == self.selection as usize
}) })
.unwrap_or_default()
}) })
.count() > 0 .count() > 0
} }
@ -623,8 +621,7 @@ impl BranchListComponent {
let is_head = displaybranch let is_head = displaybranch
.local_details() .local_details()
.map(|details| details.is_head) .is_some_and(|details| details.is_head);
.unwrap_or_default();
let is_head_str = let is_head_str =
if is_head { HEAD_SYMBOL } else { EMPTY_SYMBOL }; if is_head { HEAD_SYMBOL } else { EMPTY_SYMBOL };
let upstream_tracking_str = match displaybranch.details { let upstream_tracking_str = match displaybranch.details {

View File

@ -23,7 +23,6 @@ use ratatui::{
text::{Line, Span, Text}, text::{Line, Span, Text},
Frame, Frame,
}; };
use std::clone::Clone;
use std::{borrow::Cow, cell::Cell}; use std::{borrow::Cow, cell::Cell};
use sync::CommitTags; use sync::CommitTags;

View File

@ -135,7 +135,7 @@ impl CommitDetailsComponent {
} }
fn is_compare(&self) -> bool { fn is_compare(&self) -> bool {
self.commit.map(|p| p.other.is_some()).unwrap_or_default() self.commit.is_some_and(|p| p.other.is_some())
} }
} }

View File

@ -30,8 +30,8 @@ use ratatui::{
Frame, Frame,
}; };
use std::{ use std::{
borrow::Cow, cell::Cell, cmp, collections::BTreeMap, borrow::Cow, cell::Cell, cmp, collections::BTreeMap, rc::Rc,
convert::TryFrom, rc::Rc, time::Instant, time::Instant,
}; };
const ELEMENTS_PER_LINE: usize = 9; const ELEMENTS_PER_LINE: usize = 9;
@ -151,11 +151,7 @@ impl CommitList {
marked.windows(2).all(|w| w[0].0 + 1 == w[1].0); marked.windows(2).all(|w| w[0].0 + 1 == w[1].0);
let yank = if marked_consecutive { let yank = if marked_consecutive {
format!( format!("{}^..{}", first.1, last.1)
"{}^..{}",
first.1.to_string(),
last.1.to_string()
)
} else { } else {
marked marked
.iter() .iter()
@ -248,8 +244,7 @@ impl CommitList {
//note: set highlights to none if there is no highlight //note: set highlights to none if there is no highlight
self.highlights = if highlighting self.highlights = if highlighting
.as_ref() .as_ref()
.map(|set| set.is_empty()) .is_some_and(|set| set.is_empty())
.unwrap_or_default()
{ {
None None
} else { } else {
@ -718,8 +713,7 @@ impl CommitList {
self.highlights self.highlights
.as_ref() .as_ref()
.map(|highlights| highlights.contains(&commit)) .is_some_and(|highlights| highlights.contains(&commit))
.unwrap_or_default()
} }
fn needs_data(&self, idx: usize, idx_max: usize) -> bool { fn needs_data(&self, idx: usize, idx_max: usize) -> bool {
@ -749,8 +743,7 @@ impl CommitList {
let index_in_sync = self let index_in_sync = self
.items .items
.index_offset_raw() .index_offset_raw()
.map(|index| want_min == index) .is_some_and(|index| want_min == index);
.unwrap_or_default();
if !index_in_sync || !self.is_list_in_sync() || force { if !index_in_sync || !self.is_list_in_sync() || force {
let commits = sync::get_commits_info( let commits = sync::get_commits_info(

View File

@ -146,10 +146,7 @@ impl DiffComponent {
} }
/// ///
fn can_scroll(&self) -> bool { fn can_scroll(&self) -> bool {
self.diff self.diff.as_ref().is_some_and(|diff| diff.lines > 1)
.as_ref()
.map(|diff| diff.lines > 1)
.unwrap_or_default()
} }
/// ///
pub fn current(&self) -> (String, bool) { pub fn current(&self) -> (String, bool) {

View File

@ -20,7 +20,7 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph}, widgets::{Block, BorderType, Borders, Clear, Paragraph},
Frame, Frame,
}; };
use std::{borrow::Cow, cmp, convert::TryFrom}; use std::{borrow::Cow, cmp};
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///

View File

@ -81,7 +81,6 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Paragraph, Wrap}, widgets::{Block, BorderType, Borders, Paragraph, Wrap},
Frame, Frame,
}; };
use std::convert::From;
/// creates accessors for a list of components /// creates accessors for a list of components
/// ///

View File

@ -15,8 +15,8 @@ use ratatui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap},
Frame, Frame,
}; };
use std::convert::TryFrom;
use ui::style::SharedTheme; use ui::style::SharedTheme;
pub struct MsgComponent { pub struct MsgComponent {
title: String, title: String,
msg: String, msg: String,

View File

@ -30,7 +30,7 @@ use ratatui::{
Frame, Frame,
}; };
use std::{borrow::Cow, fmt::Write}; use std::{borrow::Cow, fmt::Write};
use std::{collections::BTreeSet, convert::From, path::Path}; use std::{collections::BTreeSet, path::Path};
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
@ -125,8 +125,7 @@ impl RevisionFilesComponent {
if self if self
.revision .revision
.as_ref() .as_ref()
.map(|commit| commit.id == result.commit) .is_some_and(|commit| commit.id == result.commit)
.unwrap_or_default()
{ {
if let Ok(last) = result.result { if let Ok(last) = result.result {
let filenames: Vec<&Path> = last let filenames: Vec<&Path> = last

View File

@ -18,7 +18,7 @@ use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType}; use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, text::Span, Frame}; use ratatui::{backend::Backend, layout::Rect, text::Span, Frame};
use std::{borrow::Cow, cell::Cell, convert::From, path::Path}; use std::{borrow::Cow, cell::Cell, path::Path};
//TODO: use new `filetreelist` crate //TODO: use new `filetreelist` crate
@ -554,7 +554,6 @@ impl Component for StatusTreeComponent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use asyncgit::StatusItemType;
fn string_vec_to_status(items: &[&str]) -> Vec<StatusItem> { fn string_vec_to_status(items: &[&str]) -> Vec<StatusItem> {
items items

View File

@ -26,7 +26,7 @@ use ratatui::{
widgets::{Block, Borders, Clear, Paragraph}, widgets::{Block, Borders, Clear, Paragraph},
Frame, Frame,
}; };
use std::{cell::Cell, convert::TryInto}; use std::cell::Cell;
use ui::style::SharedTheme; use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
@ -296,9 +296,7 @@ impl SubmodulesListComponent {
} }
fn can_open_submodule(&self) -> bool { fn can_open_submodule(&self) -> bool {
self.selected_entry() self.selected_entry().is_some_and(|s| s.status.is_in_wd())
.map(|s| s.status.is_in_wd())
.unwrap_or_default()
} }
//TODO: dedup this almost identical with BranchListComponent //TODO: dedup this almost identical with BranchListComponent

View File

@ -29,7 +29,7 @@ use ratatui::{
widgets::{Block, Borders, Wrap}, widgets::{Block, Borders, Wrap},
Frame, Frame,
}; };
use std::{cell::Cell, convert::From, path::Path}; use std::{cell::Cell, path::Path};
pub struct SyntaxTextComponent { pub struct SyntaxTextComponent {
repo: RepoPathRef, repo: RepoPathRef,
@ -105,8 +105,7 @@ impl SyntaxTextComponent {
let already_loaded = self let already_loaded = self
.current_file .current_file
.as_ref() .as_ref()
.map(|(current_file, _)| current_file == &path) .is_some_and(|(current_file, _)| current_file == &path);
.unwrap_or_default();
if !already_loaded { if !already_loaded {
//TODO: fetch file content async aswell //TODO: fetch file content async aswell

View File

@ -36,7 +36,6 @@ use ratatui::{
}, },
Frame, Frame,
}; };
use std::convert::TryInto;
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///

View File

@ -21,7 +21,6 @@ use ratatui::{
}; };
use std::cell::Cell; use std::cell::Cell;
use std::cell::OnceCell; use std::cell::OnceCell;
use std::convert::From;
use tui_textarea::{CursorMove, Input, Key, Scrolling, TextArea}; use tui_textarea::{CursorMove, Input, Key, Scrolling, TextArea};
/// ///

View File

@ -4,7 +4,6 @@ use anyhow::{bail, Result};
use asyncgit::StatusItem; use asyncgit::StatusItem;
use std::{ use std::{
collections::BTreeSet, collections::BTreeSet,
convert::TryFrom,
ffi::OsStr, ffi::OsStr,
ops::{Index, IndexMut}, ops::{Index, IndexMut},
path::Path, path::Path,

View File

@ -128,11 +128,9 @@ impl ItemBatch {
self.items.extend(commits.into_iter().map(|c| { self.items.extend(commits.into_iter().map(|c| {
let id = c.id; let id = c.id;
let mut entry = LogEntry::from(c); let mut entry = LogEntry::from(c);
if highlighted if highlighted.as_ref().is_some_and(|highlighted| {
.as_ref() highlighted.contains(&id)
.map(|highlighted| highlighted.contains(&id)) }) {
.unwrap_or_default()
{
entry.highlighted = true; entry.highlighted = true;
} }
entry entry

View File

@ -119,7 +119,6 @@ impl KeyConfig {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crossterm::event::{KeyCode, KeyModifiers};
use std::fs; use std::fs;
use std::io::Write; use std::io::Write;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;

View File

@ -32,7 +32,6 @@ use ratatui::{
style::{Color, Style}, style::{Color, Style},
widgets::{Block, BorderType, Borders, Paragraph}, widgets::{Block, BorderType, Borders, Paragraph},
}; };
use std::convert::Into;
/// what part of the screen is focused /// what part of the screen is focused
#[derive(PartialEq)] #[derive(PartialEq)]

View File

@ -12,7 +12,6 @@ use ratatui::{
widgets::Widget, widgets::Widget,
Frame, Frame,
}; };
use std::convert::TryFrom;
pub enum Orientation { pub enum Orientation {
Vertical, Vertical,

View File

@ -8,7 +8,6 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, Widget}, widgets::{Block, Borders, List, ListItem, Widget},
Frame, Frame,
}; };
use std::iter::Iterator;
/// ///
struct ScrollableList<'b, L, S> struct ScrollableList<'b, L, S>

View File

@ -354,7 +354,6 @@ impl Default for Theme {
mod tests { mod tests {
use super::*; use super::*;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use std::io::Write;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
#[test] #[test]