chore: apply clippy lints
This commit is contained in:
parent
b07f076634
commit
1e0fa7279f
10 changed files with 20 additions and 29 deletions
2
build.rs
2
build.rs
|
@ -18,7 +18,7 @@ use std::process::Command;
|
|||
|
||||
fn main() {
|
||||
let output = Command::new("git")
|
||||
.args(&["rev-parse", "HEAD"])
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.expect("error in git command, is git installed?");
|
||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Ctx {
|
|||
self.db.add_site(&db_site).await?;
|
||||
let page = Page::from_site(&self.settings, db_site);
|
||||
page.update(&page.branch)?;
|
||||
if let Some(config) = page_config::Config::load(&page.path, &page.branch) {
|
||||
if let Some(_config) = page_config::Config::load(&page.path, &page.branch) {
|
||||
unimplemented!();
|
||||
}
|
||||
Ok(page)
|
||||
|
@ -78,7 +78,7 @@ impl Ctx {
|
|||
.unwrap();
|
||||
}
|
||||
rx.await.unwrap()?;
|
||||
if let Some(config) = page_config::Config::load(&page.path, &page.branch) {
|
||||
if let Some(_config) = page_config::Config::load(&page.path, &page.branch) {
|
||||
unimplemented!();
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -23,7 +23,6 @@ use sqlx::types::time::OffsetDateTime;
|
|||
use sqlx::ConnectOptions;
|
||||
use sqlx::PgPool;
|
||||
use tracing::error;
|
||||
use url::quirks::hostname;
|
||||
|
||||
use crate::errors::*;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
use actix_web::{web, HttpResponse, Responder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
use crate::errors::*;
|
||||
use crate::page::Page;
|
||||
|
|
|
@ -187,12 +187,10 @@ fn read_file_inner(
|
|||
}
|
||||
|
||||
fn file_not_found(e: git2::Error) -> ServiceError {
|
||||
if e.code() == ErrorCode::NotFound {
|
||||
if e.class() == ErrorClass::Tree {
|
||||
return ServiceError::FileNotFound;
|
||||
}
|
||||
if e.code() == ErrorCode::NotFound && e.class() == ErrorClass::Tree {
|
||||
return ServiceError::FileNotFound;
|
||||
}
|
||||
return e.into();
|
||||
e.into()
|
||||
}
|
||||
let entry = tree.get_path(Path::new(path)).map_err(file_not_found)?;
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@ impl Config {
|
|||
branch: &str,
|
||||
policies: &'a [Policy<'a>],
|
||||
) -> Option<&'a Policy<'a>> {
|
||||
let repo = git2::Repository::open(&repo_path).unwrap();
|
||||
let repo = git2::Repository::open(repo_path).unwrap();
|
||||
|
||||
let branch = repo.find_branch(&branch, git2::BranchType::Local).unwrap();
|
||||
let branch = repo.find_branch(branch, git2::BranchType::Local).unwrap();
|
||||
// let tree = head.peel_to_tree().unwrap();
|
||||
let branch = branch.into_reference();
|
||||
let tree = branch.peel_to_tree().unwrap();
|
||||
|
@ -114,10 +114,7 @@ impl Config {
|
|||
if let Some(name) = x.name() {
|
||||
if policies.iter().any(|p| p.rel_path == name) {
|
||||
let mode: GitFileMode = x.into();
|
||||
match mode {
|
||||
GitFileMode::Executable | GitFileMode::Regular => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(mode, GitFileMode::Executable | GitFileMode::Regular)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -142,7 +139,7 @@ impl Config {
|
|||
}
|
||||
|
||||
fn load_json(c: &str) -> Config {
|
||||
serde_json::from_str(&c).unwrap()
|
||||
serde_json::from_str(c).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ pub fn context(s: &Settings) -> Context {
|
|||
ctx
|
||||
}
|
||||
|
||||
pub fn auth_ctx(username: Option<&str>, s: &Settings) -> Context {
|
||||
pub fn auth_ctx(_username: Option<&str>, s: &Settings) -> Context {
|
||||
let mut ctx = Context::new();
|
||||
let footer = Footer::new(s);
|
||||
ctx.insert("footer", &footer);
|
||||
|
|
|
@ -38,9 +38,9 @@ impl<'a> Preview<'a> {
|
|||
}
|
||||
|
||||
pub fn extract(&self, hostname: &'a str) -> Option<&'a str> {
|
||||
if !hostname.contains(&self.delimiter)
|
||||
|| !hostname.contains(&self.prefix)
|
||||
|| !hostname.contains(&self.base)
|
||||
if !hostname.contains(self.delimiter)
|
||||
|| !hostname.contains(self.prefix)
|
||||
|| !hostname.contains(self.base)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ async fn index(req: HttpRequest, ctx: AppCtx) -> ServiceResult<impl Responder> {
|
|||
if host.contains(&ctx.settings.page.base_domain) {
|
||||
let extractor = crate::preview::Preview::new(&ctx);
|
||||
if let Some(preview_branch) = extractor.extract(host) {
|
||||
let res = if ctx.db.hostname_exists(&host).await? {
|
||||
let path = crate::utils::get_website_path(&ctx.settings, &host);
|
||||
let res = if ctx.db.hostname_exists(host).await? {
|
||||
let path = crate::utils::get_website_path(&ctx.settings, host);
|
||||
let content =
|
||||
crate::git::read_preview_file(&path, preview_branch, req.uri().path())?;
|
||||
let mime = if let Some(mime) = content.mime.first_raw() {
|
||||
|
@ -75,7 +75,7 @@ async fn index(req: HttpRequest, ctx: AppCtx) -> ServiceResult<impl Responder> {
|
|||
|
||||
// TODO: custom domains.
|
||||
if ctx.db.hostname_exists(host).await? {
|
||||
let path = crate::utils::get_website_path(&ctx.settings, &host);
|
||||
let path = crate::utils::get_website_path(&ctx.settings, host);
|
||||
let content = crate::git::read_file(&path, req.uri().path())?;
|
||||
let mime = if let Some(mime) = content.mime.first_raw() {
|
||||
mime
|
||||
|
|
|
@ -16,22 +16,20 @@
|
|||
*/
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use config::{Config, ConfigError, Environment, File};
|
||||
use derive_more::Display;
|
||||
#[cfg(not(test))]
|
||||
use tracing::{error, warn};
|
||||
use tracing::warn;
|
||||
|
||||
#[cfg(test)]
|
||||
use std::{println as warn, println as error};
|
||||
use std::println as warn;
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use url::Url;
|
||||
|
||||
use crate::errors::*;
|
||||
use crate::page::Page;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Server {
|
||||
|
@ -178,7 +176,7 @@ impl Settings {
|
|||
}
|
||||
|
||||
if !path.exists() {
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
std::fs::create_dir_all(path).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue