From d42c27483276161c8709620843312d0450cc2667 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 2 Feb 2024 17:13:06 +0800 Subject: [PATCH] Allow find tag by prefix hash --- src/repo.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/repo.rs b/src/repo.rs index 6d3b20f8f8..107a4730f3 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1963,6 +1963,20 @@ impl Repository { } } + /// Lookup a tag object by prefix hash from the repository. + pub fn find_tag_by_prefix(&self, prefix_hash: &str) -> Result, Error> { + let mut raw = ptr::null_mut(); + unsafe { + try_call!(raw::git_tag_lookup_prefix( + &mut raw, + self.raw, + Oid::from_str(prefix_hash)?.raw(), + prefix_hash.len() + )); + Ok(Binding::from_raw(raw)) + } + } + /// Delete an existing tag reference. /// /// The tag name will be checked for validity, see `tag` for some rules