diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-31 09:17:49 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-31 09:17:49 +0000 |
| commit | 3d6901831904141166d9ed8f47813c45cba109b6 (patch) | |
| tree | 44d0a431b148ad301971fadb7017dfbf937e45ff /src/git | |
| parent | 08ab20509b9c730d3db98dd6e9deb5e2b548979e (diff) | |
purgatory: fix state event receive code
Diffstat (limited to 'src/git')
| -rw-r--r-- | src/git/authorization.rs | 1 | ||||
| -rw-r--r-- | src/git/mod.rs | 24 |
2 files changed, 24 insertions, 1 deletions
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( | |||
| 149 | "Found {} non-refs/nostr/ refs - checking state authorization", | 149 | "Found {} non-refs/nostr/ refs - checking state authorization", |
| 150 | state_refs.len() | 150 | state_refs.len() |
| 151 | ); | 151 | ); |
| 152 | |||
| 153 | let auth_result = get_state_authorization_for_specific_owner_repo( | 152 | let auth_result = get_state_authorization_for_specific_owner_repo( |
| 154 | database, | 153 | database, |
| 155 | identifier, | 154 | 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 { | |||
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | /// Check if a oid exists in the repository | ||
| 78 | /// | ||
| 79 | /// # Arguments | ||
| 80 | /// * `repo_path` - Path to the bare git repository | ||
| 81 | /// * `oid` - The commit hash to check | ||
| 82 | /// | ||
| 83 | /// # Returns | ||
| 84 | /// True if the commit exists in the repository, false otherwise | ||
| 85 | pub fn oid_exists(repo_path: &Path, oid: &str) -> bool { | ||
| 86 | let output = Command::new("git") | ||
| 87 | .args(["cat-file", "-e", oid]) | ||
| 88 | .current_dir(repo_path) | ||
| 89 | .output(); | ||
| 90 | |||
| 91 | match output { | ||
| 92 | Ok(result) => result.status.success(), | ||
| 93 | Err(_) => false, | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | pub fn is_valid_oid(oid: &str) -> bool { | ||
| 98 | oid.len() >= 5 && oid.len() <= 40 && oid.chars().all(|c| c.is_digit(16)) | ||
| 99 | } | ||
| 100 | |||
| 77 | /// Set the repository HEAD to point to a branch | 101 | /// Set the repository HEAD to point to a branch |
| 78 | /// | 102 | /// |
| 79 | /// This updates the HEAD symbolic ref to point to the specified branch. | 103 | /// This updates the HEAD symbolic ref to point to the specified branch. |