fixed clippy errors
Rust lint and build / Rust CI (push) Successful in 1m57s

This commit is contained in:
2026-06-03 10:00:19 +02:00
parent 81d775a7dd
commit f61a4aa684
5 changed files with 38 additions and 36 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ impl WikiGraph {
); );
} }
println!(""); println!();
// Edges // Edges
for (source, targets) in &self.edges { for (source, targets) in &self.edges {
+15 -14
View File
@@ -106,11 +106,12 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
for line in stdout.lines() { for line in stdout.lines() {
if line.starts_with("---ENTRY---|") { if line.starts_with("---ENTRY---|") {
// Push previous // Push previous
if let Some(entry) = current_entry.take() { if let Some(entry) = current_entry.take()
if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) { && !entry.files.is_empty()
&& !existing_hashes.contains(&entry.hash)
{
new_entries.push(entry); new_entries.push(entry);
} }
}
// Parse new // Parse new
let parts: Vec<&str> = line.split('|').collect(); let parts: Vec<&str> = line.split('|').collect();
@@ -132,8 +133,9 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
let raw_path = line.trim(); let raw_path = line.trim();
// Check if file belongs to the wiki directory // Check if file belongs to the wiki directory
if prefix.is_empty() || raw_path.starts_with(&prefix) { if (prefix.is_empty() || raw_path.starts_with(&prefix))
if let Some(entry) = current_entry.as_mut() { && let Some(entry) = current_entry.as_mut()
{
// Strip the prefix to get the relative path inside the wiki // Strip the prefix to get the relative path inside the wiki
let clean_path = if prefix.is_empty() { let clean_path = if prefix.is_empty() {
raw_path.to_string() raw_path.to_string()
@@ -150,14 +152,14 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
} }
} }
} }
}
// Push last // Push last
if let Some(entry) = current_entry { if let Some(entry) = current_entry
if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) { && !entry.files.is_empty()
&& !existing_hashes.contains(&entry.hash)
{
new_entries.push(entry); new_entries.push(entry);
} }
}
if new_entries.is_empty() { if new_entries.is_empty() {
println!("No new commits touching the wiki directory found."); println!("No new commits touching the wiki directory found.");
@@ -180,12 +182,11 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
pub async fn load_changelog(root_dir: &Path) -> Vec<ChangelogEntry> { pub async fn load_changelog(root_dir: &Path) -> Vec<ChangelogEntry> {
let path = root_dir.join("_changelog.toml"); let path = root_dir.join("_changelog.toml");
if path.exists() { if path.exists()
if let Ok(content) = fs::read_to_string(path).await { && let Ok(content) = fs::read_to_string(path).await
if let Ok(config) = toml::from_str::<ChangelogConfig>(&content) { && let Ok(config) = toml::from_str::<ChangelogConfig>(&content)
{
return config.entries; return config.entries;
} }
}
}
Vec::new() Vec::new()
} }
+5 -4
View File
@@ -1,5 +1,6 @@
use anyhow::{Context, Result, anyhow}; use anyhow::{Context, Result, anyhow};
use colored::Colorize; use colored::Colorize;
use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use tokio::fs; use tokio::fs;
@@ -59,7 +60,7 @@ async fn list_entries(root: &PathBuf) -> Result<()> {
Ok(()) Ok(())
} }
fn check_file_status(root: &PathBuf, filename: Option<String>) -> String { fn check_file_status(root: &Path, filename: Option<String>) -> String {
match filename { match filename {
Some(f) => { Some(f) => {
let path = root.join("images").join(&f); let path = root.join("images").join(&f);
@@ -73,7 +74,7 @@ fn check_file_status(root: &PathBuf, filename: Option<String>) -> String {
} }
} }
async fn create_entry(root: &PathBuf, title: &str, category: Option<String>) -> Result<()> { async fn create_entry(root: &Path, title: &str, category: Option<String>) -> Result<()> {
let slug: String = title let slug: String = title
.trim() .trim()
.to_lowercase() .to_lowercase()
@@ -139,7 +140,7 @@ content_file = "{}"
Ok(()) Ok(())
} }
async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> { async fn remove_entry(root: &Path, name: &str) -> Result<()> {
let toml_path = root.join(format!("{}.toml", name)); let toml_path = root.join(format!("{}.toml", name));
if !toml_path.exists() { if !toml_path.exists() {
@@ -176,7 +177,7 @@ async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> {
Ok(()) Ok(())
} }
async fn inspect_entry(root: &PathBuf, name: &str) -> Result<()> { async fn inspect_entry(root: &Path, name: &str) -> Result<()> {
let toml_path = root.join(format!("{}.toml", name)); let toml_path = root.join(format!("{}.toml", name));
if !toml_path.exists() { if !toml_path.exists() {
return Err(anyhow!("Entry '{}' not found", name)); return Err(anyhow!("Entry '{}' not found", name));
+1 -1
View File
@@ -114,7 +114,7 @@ async fn main() -> anyhow::Result<()> {
.route("/changelog", get(render_changelog_handler)) .route("/changelog", get(render_changelog_handler))
.nest_service( .nest_service(
"/images", "/images",
tower_http::services::ServeDir::new(&shared_state.docs_dir.join("images")), tower_http::services::ServeDir::new(shared_state.docs_dir.join("images")),
) )
.nest_service( .nest_service(
"/assets", "/assets",
+2 -2
View File
@@ -85,7 +85,7 @@ impl<'a> Iterator for Renderer<'a> {
Event::Start(Tag::CodeBlock(kind)) => { Event::Start(Tag::CodeBlock(kind)) => {
let mut code_content = String::new(); let mut code_content = String::new();
while let Some(inner_event) = self.inner.next() { for inner_event in self.inner.by_ref() {
match inner_event { match inner_event {
Event::End(TagEnd::CodeBlock) => break, Event::End(TagEnd::CodeBlock) => break,
Event::Text(code) => code_content.push_str(&code), Event::Text(code) => code_content.push_str(&code),
@@ -111,7 +111,7 @@ impl<'a> Iterator for Renderer<'a> {
); );
Some(Event::Html(CowStr::Boxed(rendered_html.into_boxed_str()))) Some(Event::Html(CowStr::Boxed(rendered_html.into_boxed_str())))
} }
_ => return Some(event), _ => Some(event),
} }
} }
} }