repo: Add require_rev method

The `resolve_rev` C method should really have been
`resolve_rev_optional` from the start - it is more obviously wrong
in Rust because the input parameter `allows_noent` controls
whether the returned `Option` can ever be `None`.

I debated adding this to the C bindings, and may still do so,
but eh it's faster to write + ship in Rust, and the future of ostree is
Rust anyways.
This commit is contained in:
Colin Walters committed 2022-05-06 12:53:57 -04:00
1 parent faaf0457fd
commit 440d872f68
2 files changed
+11

No files matched your search

+7
View File
@@ -175,6 +175,13 @@ impl Repo {
}
}
/// Resolve a refspec to a commit SHA256.
/// Returns an error if the refspec does not exist.
pub fn require_rev(&self, refspec: &str) -> Result<glib::GString, Error> {
// SAFETY: Since we said `false` for "allow_noent", this function must return a value
Ok(self.resolve_rev(refspec, false)?.unwrap())
}
/// Write a content object from provided input.
pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
&self,