mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
fix: resolve fmt and clippy violations
This commit is contained in:
+4
-15
@@ -188,10 +188,8 @@ fn clone_url_prs_identifier_for_relay(
|
||||
// Scheme: http or https only, case-insensitive.
|
||||
let rest = if let Some(r) = strip_prefix_ignore_ascii_case(url, "http://") {
|
||||
r
|
||||
} else if let Some(r) = strip_prefix_ignore_ascii_case(url, "https://") {
|
||||
r
|
||||
} else {
|
||||
return None;
|
||||
strip_prefix_ignore_ascii_case(url, "https://")?
|
||||
};
|
||||
|
||||
// Reject query strings and fragments outright.
|
||||
@@ -200,10 +198,7 @@ fn clone_url_prs_identifier_for_relay(
|
||||
}
|
||||
|
||||
// Split authority and path on the first `/`.
|
||||
let slash_idx = match rest.find('/') {
|
||||
Some(i) => i,
|
||||
None => return None,
|
||||
};
|
||||
let slash_idx = rest.find('/')?;
|
||||
let authority = &rest[..slash_idx];
|
||||
let path = &rest[slash_idx..]; // includes leading `/`.
|
||||
|
||||
@@ -213,10 +208,7 @@ fn clone_url_prs_identifier_for_relay(
|
||||
|
||||
let path = path.trim_end_matches('/');
|
||||
|
||||
let inner = match path.strip_prefix(&format!("/{}/", PRS_URL_PREFIX)) {
|
||||
Some(s) => s,
|
||||
None => return None,
|
||||
};
|
||||
let inner = path.strip_prefix(&format!("/{}/", PRS_URL_PREFIX))?;
|
||||
|
||||
// Exactly two segments: `<npub>` and `<repo>.git`.
|
||||
let segments: Vec<&str> = inner.split('/').collect();
|
||||
@@ -237,10 +229,7 @@ fn clone_url_prs_identifier_for_relay(
|
||||
return None;
|
||||
}
|
||||
|
||||
let d_encoded = match repo_segment.strip_suffix(".git") {
|
||||
Some(s) => s,
|
||||
None => return None,
|
||||
};
|
||||
let d_encoded = repo_segment.strip_suffix(".git")?;
|
||||
if d_encoded.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ impl std::fmt::Debug for Nip34WritePolicy {
|
||||
}
|
||||
|
||||
impl Nip34WritePolicy {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
database: SharedDatabase,
|
||||
tombstones: crate::nostr::tombstones::Tombstones,
|
||||
|
||||
@@ -166,7 +166,7 @@ impl ReplaceableHistoryStore {
|
||||
.into_iter()
|
||||
.filter_map(|metadata| {
|
||||
let superseded_at = parse_timestamp_tag(&metadata, HISTORY_SUPERSEDED_AT_TAG)
|
||||
.or_else(|| Some(metadata.created_at));
|
||||
.or(Some(metadata.created_at));
|
||||
if superseded_at.is_some_and(|ts| ts > before_or_at) {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -295,10 +295,7 @@ impl DeletionPolicy {
|
||||
Self::a_tag_coordinates(event)
|
||||
.into_iter()
|
||||
.filter_map(|coordinate| {
|
||||
let Some((kind, coord_pubkey, identifier)) = Self::parse_coordinate(&coordinate)
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let (kind, coord_pubkey, identifier) = Self::parse_coordinate(&coordinate)?;
|
||||
|
||||
if kind == Kind::RepoState && coord_pubkey == event.pubkey {
|
||||
Some(identifier)
|
||||
|
||||
@@ -84,6 +84,7 @@ pub struct PolicyContext {
|
||||
}
|
||||
|
||||
impl PolicyContext {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
domain: impl Into<String>,
|
||||
database: SharedDatabase,
|
||||
|
||||
@@ -538,9 +538,11 @@ async fn purgatory_promotion_recovery_respects_state_tombstones() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn purgatory_promotion_tombstoned_pr_events_do_not_restore_pr_refs() {
|
||||
let fixture =
|
||||
setup_parked_announcement_with_failed_ingest_recovery("promotion-recovery-pr-tombstones", false)
|
||||
.await;
|
||||
let fixture = setup_parked_announcement_with_failed_ingest_recovery(
|
||||
"promotion-recovery-pr-tombstones",
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
|
||||
fixture
|
||||
.client
|
||||
|
||||
Reference in New Issue
Block a user