From 3d6901831904141166d9ed8f47813c45cba109b6 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 31 Dec 2025 09:17:49 +0000 Subject: purgatory: fix state event receive code --- src/git/authorization.rs | 1 - src/git/mod.rs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/git') diff --git a/src/git/authorization.rs b/src/git/authorization.rs index 9bcbdf8..6b997d8 100644 --- a/src/git/authorization.rs +++ b/src/git/authorization.rs @@ -149,7 +149,6 @@ pub async fn authorize_push( "Found {} non-refs/nostr/ refs - checking state authorization", state_refs.len() ); - let auth_result = get_state_authorization_for_specific_owner_repo( database, identifier, diff --git a/src/git/mod.rs b/src/git/mod.rs index 5c99b3e..1847c8c 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -74,6 +74,30 @@ pub fn commit_exists(repo_path: &Path, commit_hash: &str) -> bool { } } +/// Check if a oid exists in the repository +/// +/// # Arguments +/// * `repo_path` - Path to the bare git repository +/// * `oid` - The commit hash to check +/// +/// # Returns +/// True if the commit exists in the repository, false otherwise +pub fn oid_exists(repo_path: &Path, oid: &str) -> bool { + let output = Command::new("git") + .args(["cat-file", "-e", oid]) + .current_dir(repo_path) + .output(); + + match output { + Ok(result) => result.status.success(), + Err(_) => false, + } +} + +pub fn is_valid_oid(oid: &str) -> bool { + oid.len() >= 5 && oid.len() <= 40 && oid.chars().all(|c| c.is_digit(16)) +} + /// Set the repository HEAD to point to a branch /// /// This updates the HEAD symbolic ref to point to the specified branch. -- cgit v1.2.3