Skip to content

Commit

Permalink
fix: tag_foreach should respect callback return type (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn authored Aug 26, 2024
1 parent c9e7c3a commit cfa1667
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,24 @@ impl Repository {
})
}

#[napi]
/// Lookup a tag object by prefix hash from the repository.
pub fn find_tag_by_prefix(
&self,
env: Env,
this: Reference<Repository>,
prefix_hash: String,
) -> Result<Tag> {
Ok(Tag {
inner: this.share_with(env, |repo| {
repo
.inner
.find_tag_by_prefix(&prefix_hash)
.convert(format!("Find tag from OID [{prefix_hash}] failed"))
})?,
})
}

#[napi]
/// Delete an existing tag reference.
///
Expand Down Expand Up @@ -701,13 +719,13 @@ impl Repository {
#[napi]
/// iterate over all tags calling `cb` on each.
/// the callback is provided the tag id and name
pub fn tag_foreach(&self, cb: Function<(String, Buffer), ()>) -> Result<()> {
pub fn tag_foreach(&self, cb: Function<(String, Buffer), bool>) -> Result<()> {
self
.inner
.tag_foreach(|oid, name| {
let oid = oid.to_string();
let name = name.to_vec();
cb.call((oid, name.into())).is_ok()
cb.call((oid, name.into())).unwrap_or(false)
})
.convert_without_message()
}
Expand Down

0 comments on commit cfa1667

Please sign in to comment.