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

View File

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

View File

@ -4,7 +4,7 @@ version = "0.24.3"
authors = ["extrawurst <mail@rusticorn.com>"]
description = "blazing fast terminal-ui for git"
edition = "2021"
rust-version = "1.65"
rust-version = "1.70"
exclude = [".github/*", ".vscode/*", "assets/*"]
homepage = "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-nightly:
cargo +nightly c
cargo +nightly clippy --workspace --all-features
cargo +nightly t
deny:
cargo deny check

View File

@ -215,7 +215,7 @@ All contain a single binary file
### 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)
- To build openssl dependency (see https://docs.rs/openssl/latest/openssl/)

View File

@ -201,7 +201,9 @@ impl AsyncLog {
) -> Result<()> {
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 mut walker =
LogWalker::new(&r, LIMIT_COUNT)?.filter(filter);

View File

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

View File

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

View File

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

View File

@ -1,3 +1,5 @@
use std::fmt::Display;
use super::RepoPath;
use crate::{error::Result, sync::repository::repo};
use git2::{Commit, Error, Oid};
@ -46,9 +48,12 @@ impl CommitId {
}
}
impl ToString for CommitId {
fn to_string(&self) -> String {
self.0.to_string()
impl Display for CommitId {
fn fmt(
&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()?;
// if `origin` exists return that
let found_origin = remotes.iter().any(|r| {
r.map(|r| r == DEFAULT_REMOTE_NAME).unwrap_or_default()
});
let found_origin = remotes
.iter()
.any(|r| r.is_some_and(|r| r == DEFAULT_REMOTE_NAME));
if found_origin {
return Ok(DEFAULT_REMOTE_NAME.into());
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ use ratatui::{
Frame,
};
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_width::UnicodeWidthStr;
@ -125,8 +125,7 @@ impl RevisionFilesComponent {
if self
.revision
.as_ref()
.map(|commit| commit.id == result.commit)
.unwrap_or_default()
.is_some_and(|commit| commit.id == result.commit)
{
if let Ok(last) = result.result {
let filenames: Vec<&Path> = last

View File

@ -18,7 +18,7 @@ use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event;
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
@ -554,7 +554,6 @@ impl Component for StatusTreeComponent {
#[cfg(test)]
mod tests {
use super::*;
use asyncgit::StatusItemType;
fn string_vec_to_status(items: &[&str]) -> Vec<StatusItem> {
items

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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