refactor: cleanup pedantic clippy in forge-forgejo crate
Some checks are pending
Rust / build (push) Successful in 1m21s
Release Please / Release-plz (push) Waiting to run
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Some checks are pending
Rust / build (push) Successful in 1m21s
Release Please / Release-plz (push) Waiting to run
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
This commit is contained in:
parent
6acefda5d3
commit
067296ffab
7 changed files with 32 additions and 31 deletions
|
@ -6,6 +6,15 @@ license = { workspace = true }
|
|||
repository = { workspace = true }
|
||||
description = "Forgejo support for git-next, the trunk-based development manager"
|
||||
|
||||
[lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||
|
||||
[dependencies]
|
||||
git-next-core = { workspace = true }
|
||||
|
||||
|
@ -32,12 +41,3 @@ tokio = { workspace = true }
|
|||
# Testing
|
||||
assert2 = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
|
||||
[lints.clippy]
|
||||
nursery = { level = "warn", priority = -1 }
|
||||
# pedantic = "warn"
|
||||
unwrap_used = "warn"
|
||||
expect_used = "warn"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||
|
|
|
@ -4,6 +4,8 @@ mod tests;
|
|||
|
||||
mod webhook;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
use git_next_core::{
|
||||
self as core,
|
||||
git::{self, forge::commit::Status},
|
||||
|
@ -20,6 +22,7 @@ pub struct ForgeJo {
|
|||
net: Network,
|
||||
}
|
||||
impl ForgeJo {
|
||||
#[must_use]
|
||||
pub const fn new(repo_details: git::RepoDetails, net: Network) -> Self {
|
||||
Self { repo_details, net }
|
||||
}
|
||||
|
@ -37,10 +40,9 @@ impl git::ForgeLike for ForgeJo {
|
|||
let authorization = msg.header("authorization");
|
||||
tracing::info!(?authorization, %expected, "is message authorised?");
|
||||
authorization
|
||||
.and_then(|header| header.strip_prefix("Basic ").map(|v| v.to_owned()))
|
||||
.and_then(|header| header.strip_prefix("Basic ").map(ToOwned::to_owned))
|
||||
.and_then(|value| WebhookAuth::try_new(value.as_str()).ok())
|
||||
.map(|auth| &auth == expected)
|
||||
.unwrap_or(false)
|
||||
.is_some_and(|auth| &auth == expected)
|
||||
}
|
||||
|
||||
fn parse_webhook_body(
|
||||
|
@ -75,10 +77,8 @@ impl git::ForgeLike for ForgeJo {
|
|||
Ok(response) => match response.response_body() {
|
||||
Some(status) => match status.state {
|
||||
ForgejoState::Success => Status::Pass,
|
||||
ForgejoState::Pending => Status::Pending,
|
||||
ForgejoState::Failure => Status::Fail,
|
||||
ForgejoState::Error => Status::Fail,
|
||||
ForgejoState::Blank => Status::Pending,
|
||||
ForgejoState::Pending | ForgejoState::Blank => Status::Pending,
|
||||
ForgejoState::Failure | ForgejoState::Error => Status::Fail,
|
||||
},
|
||||
None => {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
|
|
|
@ -284,7 +284,7 @@ mod forgejo {
|
|||
|
||||
let forge = given::a_forgejo_forge(&repo_details, net);
|
||||
|
||||
let_assert!(Ok(_) = forge.unregister_webhook(&webhook_id).await);
|
||||
let_assert!(Ok(()) = forge.unregister_webhook(&webhook_id).await);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -397,13 +397,15 @@ mod forgejo {
|
|||
repo_path,
|
||||
token,
|
||||
};
|
||||
let hook1 = with::ReturnedWebhook::new(given::a_forgejo_webhook_id(), &repo_listen_url);
|
||||
let hook2 = with::ReturnedWebhook::new(given::a_forgejo_webhook_id(), &repo_listen_url);
|
||||
let hook3 = with::ReturnedWebhook::new(
|
||||
let hook_1 =
|
||||
with::ReturnedWebhook::new(given::a_forgejo_webhook_id(), &repo_listen_url);
|
||||
let hook_2 =
|
||||
with::ReturnedWebhook::new(given::a_forgejo_webhook_id(), &repo_listen_url);
|
||||
let hook_3 = with::ReturnedWebhook::new(
|
||||
given::a_forgejo_webhook_id(),
|
||||
&given::a_repo_listen_url(&repo_details),
|
||||
);
|
||||
let hooks = [hook1, hook2, hook3];
|
||||
let hooks = [hook_1, hook_2, hook_3];
|
||||
|
||||
// there are three existing webhooks, two are matching webhooks
|
||||
with::get_webhooks_by_page(1, &hooks, &mut args);
|
||||
|
@ -585,7 +587,7 @@ mod forgejo {
|
|||
a_commit_status_url(repo_details, commit).as_str(),
|
||||
StatusCode::OK,
|
||||
response.to_string().as_str(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
pub fn a_commit_status_url(
|
||||
|
@ -709,7 +711,7 @@ mod forgejo {
|
|||
a_name(),
|
||||
a_name(),
|
||||
a_name(),
|
||||
Default::default(), // no repos
|
||||
BTreeMap::default(), // no repos
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ use git_next_core::{git, webhook, BranchName, WebhookId};
|
|||
use std::collections::HashMap;
|
||||
|
||||
mod list;
|
||||
mod parse;
|
||||
mod parser;
|
||||
mod register;
|
||||
mod unregister;
|
||||
|
||||
pub use list::list;
|
||||
pub use parse::parse_body;
|
||||
pub use parser::parse_body;
|
||||
pub use register::register;
|
||||
pub use unregister::unregister;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use git_next_core::server::RepoListenUrl;
|
||||
//
|
||||
use git_next_core::{git, RegisteredWebhook, WebhookAuth, WebhookId};
|
||||
use git_next_core::{git, server::RepoListenUrl, RegisteredWebhook, WebhookAuth, WebhookId};
|
||||
|
||||
use kxio::network;
|
||||
use tracing::{info, warn};
|
||||
use secrecy::ExposeSecret as _;
|
||||
use tracing::{info, instrument, warn};
|
||||
|
||||
use crate::webhook;
|
||||
use crate::webhook::Hook;
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn register(
|
||||
repo_details: &git::RepoDetails,
|
||||
repo_listen_url: &RepoListenUrl,
|
||||
|
@ -26,7 +26,6 @@ pub async fn register(
|
|||
|
||||
let hostname = &repo_details.forge.hostname();
|
||||
let repo_path = &repo_details.repo_path;
|
||||
use secrecy::ExposeSecret;
|
||||
let token = repo_details.forge.token().expose_secret();
|
||||
let url = network::NetUrl::new(format!(
|
||||
"https://{hostname}/api/v1/repos/{repo_path}/hooks?token={token}"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
use git_next_core::{git, WebhookId};
|
||||
|
||||
use kxio::network;
|
||||
use secrecy::ExposeSecret as _;
|
||||
|
||||
pub async fn unregister(
|
||||
webhook_id: &WebhookId,
|
||||
|
@ -10,7 +11,6 @@ pub async fn unregister(
|
|||
) -> git::forge::webhook::Result<()> {
|
||||
let hostname = &repo_details.forge.hostname();
|
||||
let repo_path = &repo_details.repo_path;
|
||||
use secrecy::ExposeSecret;
|
||||
let token = repo_details.forge.token().expose_secret();
|
||||
let url = network::NetUrl::new(format!(
|
||||
"https://{hostname}/api/v1/repos/{repo_path}/hooks/{webhook_id}?token={token}"
|
||||
|
|
Loading…
Reference in a new issue