Update to edition 2024
No idea why rustfmt decided to reformat imports
- Id
- 511abd294de721239ebd80b1a328c5fa6ca4f5eb
- Author
- Caio
- Commit time
- 2025-11-07T08:33:25+01:00
Modified caca/Cargo.toml
[package]
name = "caca"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
urso = { path = "../urso" }
Modified urso/Cargo.toml
[package]
name = "urso"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
gix = { version = "0.73", default-features = false, features = ["revision", "blob-diff", "mailmap", "parallel"] }
Modified caca/src/admin.rs
return;
};
- if !path
- // path.ends_with() is deceptive AF eh
+ // path.ends_with() is deceptive AF eh
+ if path
.extension()
.and_then(|n| n.to_str())
- .is_some_and(|n| n == "html")
+ .unwrap_or_default()
+ != "html"
{
return;
}
Modified caca/src/main.rs
clippy::map_err_ignore,
clippy::map_flatten,
clippy::map_unwrap_or,
- clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wild_err_arm,
clippy::match_wildcard_for_single_variants,
clippy::mem_forget,
- clippy::mismatched_target_os,
clippy::missing_enforced_import_renames,
clippy::mut_mut,
clippy::mutex_integer,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
- clippy::string_to_string,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns,
use tokio::net::TcpListener as AsyncTcpListener;
use axum::{
+ Router,
extract::{Path as ReqPath, State},
http::{StatusCode, Uri},
response::{IntoResponse, Response},
routing::{get, post},
- Router,
};
use tower_http::{limit::RequestBodyLimitLayer, trace::TraceLayer};
if args
.iter()
.next()
- .map_or(true, |a| matches!(a.as_str(), "-h" | "--help"))
+ .is_none_or(|a| matches!(a.as_str(), "-h" | "--help"))
{
return Err(usage!().into());
}
Modified caca/src/metadata.rs
title: Option<String>,
}
-#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, serde::Serialize)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, serde::Serialize, Default)]
pub(crate) enum State {
Archived,
+ #[default]
Default,
Pinned,
-}
-
-impl Default for State {
- fn default() -> Self {
- Self::Default
- }
}
impl State {
Modified caca/src/view.rs
use std::path::Path;
use axum::{
- http::{header::CONTENT_TYPE, HeaderName, HeaderValue, StatusCode},
+ http::{HeaderName, HeaderValue, StatusCode, header::CONTENT_TYPE},
response::IntoResponse,
};
use minijinja::Environment;
let (frontmatter, content) = split_frontmatter(&data);
let mut front = std::collections::HashMap::<String, String>::new();
- if let Some(matter) = frontmatter {
- if let Err(err) = urso::config::parse(matter.data, |section, _sub, key, value| -> bool {
+ if let Some(matter) = frontmatter
+ && let Err(err) = urso::config::parse(matter.data, |section, _sub, key, value| -> bool {
if section == "page" {
front.insert(key.to_string(), String::from_utf8_lossy(value).into_owned());
} else {
);
}
true
- }) {
- tracing::warn!(?err, "discarded broken frontmatter");
- };
- }
+ })
+ {
+ tracing::warn!(?err, "discarded broken frontmatter");
+ };
// XXX could let markdown use the frontmatter too, but i don't need
// it now
Modified urso/src/lib.rs
clippy::string_add,
clippy::string_add_assign,
clippy::string_lit_as_bytes,
- clippy::string_to_string,
clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
use error::wrap_err;
use gix::{
- bstr::BStr, object::tree, objs::tree::EntryKind, odb::HeaderExt, prelude::FindExt, Object,
- Repository, Tree,
+ Object, Repository, Tree, bstr::BStr, object::tree, objs::tree::EntryKind, odb::HeaderExt,
+ prelude::FindExt,
};
// re-export
pub use gix::{
- actor::SignatureRef,
- date::parse_header,
- date::Time,
- mailmap::Snapshot as Mailmap,
- objs::{tree::EntryMode, CommitRef, TagRef},
Commit, ObjectId,
+ actor::SignatureRef,
+ date::Time,
+ date::parse_header,
+ mailmap::Snapshot as Mailmap,
+ objs::{CommitRef, TagRef, tree::EntryMode},
};
use std::{
pub mod config {
pub use gix::config::parse::Error;
- use gix::config::parse::{from_bytes, Event};
+ use gix::config::parse::{Event, from_bytes};
pub fn parse<V>(data: &[u8], mut visitor: V) -> Result<(), Error>
where
Modified caca/src/repo/feed.rs
pub(crate) fn insert(&mut self, info: T) -> bool {
if self.q.len() == self.k {
- if let Some(mut oldest) = self.q.peek_mut() {
- if oldest.0 < info {
- *oldest = Reverse(info);
- return true;
- }
+ if let Some(mut oldest) = self.q.peek_mut()
+ && oldest.0 < info
+ {
+ *oldest = Reverse(info);
+ return true;
}
} else {
self.q.push(Reverse(info));
Modified caca/src/repo/mod.rs
use std::{collections::HashSet, num::NonZeroUsize, sync::Arc};
use chrono::TimeZone;
use urso::{
+ Error, Mailmap, ObjectId, Urso, UrsoHandle,
diff::{Change, Event, Patch},
- guess_mime, Error, Mailmap, ObjectId, Urso, UrsoHandle,
+ guess_mime,
};
use crate::{
- metadata::{read_metadata, Link, Metadata, State},
- view::{self, render_markdown},
GlobalConfig,
+ metadata::{Link, Metadata, State, read_metadata},
+ view::{self, render_markdown},
};
mod feed;
// pagination url can be generated
// FIXME not quite right if the boundary is a merge commit
// better to take size+1 and trim
- if entries.len() == size {
- if let Some(first_parent) = commit.parent_ids().next() {
- next = Some((first_parent.detach(), path.display().to_string()));
- }
+ if entries.len() == size
+ && let Some(first_parent) = commit.parent_ids().next()
+ {
+ next = Some((first_parent.detach(), path.display().to_string()));
}
entries.len() < size
})?;
Modified urso/src/diff/mod.rs
use std::{borrow::Cow, ops::Range};
use gix::{
+ Commit, ObjectId, Tree,
bstr::{BStr, ByteSlice},
diff::Rewrites,
- object::tree::diff::for_each::Error as ForEachError,
object::tree::diff::Action,
object::tree::diff::Change as GixChange,
+ object::tree::diff::for_each::Error as ForEachError,
objs::tree::EntryMode,
- Commit, ObjectId, Tree,
};
mod sink;
pub(crate) use sink::{diff, similarity};
use crate::{
- error::{wrap_err, WrappedError},
+ error::{WrappedError, wrap_err},
mime::{self, File},
};
entry_mode,
id,
location,
- relation,
+ relation: _,
} => {
if let Some(event) = handle_change(&repo, location, entry_mode, true, id)? {
visitor(Event::Addition(event));
entry_mode,
id,
location,
- relation,
+ relation: _,
} => {
if let Some(event) = handle_change(&repo, location, entry_mode, false, id)? {
visitor(Event::Deletion(event));
entry_mode,
id,
copy: _,
- source_relation,
+ source_relation: _,
location,
- relation,
+ relation: _,
} => {
handle_modification(
&repo,
mime::guess_from_path(&path).map_or((None, false), |m| (Some(m.0), m.1));
// if the guess is empty, sniff it later after loading from disk
- if guessed.is_some() && !is_text && !entry_mode.is_link() {
+ if let Some(guessed) = guessed
+ && !is_text
+ && !entry_mode.is_link()
+ {
return Ok(Some(Change {
- file: File::plain(path, guessed.unwrap()),
+ file: File::plain(path, guessed),
object: repo.get_header(id.into()).map_err(DiffError::Repo)?,
patch: Patch::BinaryData,
}));
// bail if the guessed mime is not text
// if the guess is empty, sniff it later after loading from disk
- if guessed.is_some() && !is_known_text {
+ if let Some(guessed) = guessed
+ && !is_known_text
+ {
let before = repo
.get_header(previous_id.into())
.map_err(DiffError::Repo)?;
return Ok((
before,
Change {
- file: File::plain(path, guessed.unwrap()),
+ file: File::plain(path, guessed),
object: after,
patch: Patch::BinaryData,
},
Modified urso/src/rename/mod.rs
use gix::{
+ ObjectId, Tree,
bstr::{BStr, ByteSlice},
object::tree::diff::{Action, Change},
- ObjectId, Tree,
};
use std::path::PathBuf;
-use crate::error::{wrap_err, WrappedError};
+use crate::error::{WrappedError, wrap_err};
pub(crate) enum RenameError<E> {
Repo(E),
entry_mode,
id,
location,
- relation,
+ relation: _,
} = change
+ && entry_mode.is_blob()
+ && !cb(location, id.detach())
{
- if entry_mode.is_blob() && !cb(location, id.detach()) {
- return Ok(Action::Cancel);
- }
+ return Ok(Action::Cancel);
};
Ok(Action::Continue)
});