upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/git/mod.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-31 09:17:49 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-31 09:17:49 +0000
commit3d6901831904141166d9ed8f47813c45cba109b6 (patch)
tree44d0a431b148ad301971fadb7017dfbf937e45ff /src/git/mod.rs
parent08ab20509b9c730d3db98dd6e9deb5e2b548979e (diff)
purgatory: fix state event receive code
Diffstat (limited to 'src/git/mod.rs')
-rw-r--r--src/git/mod.rs24
1 files changed, 24 insertions, 0 deletions
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
85pub 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
97pub 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.