diff --git a/rust-bindings/src/repo.rs b/rust-bindings/src/repo.rs index 35a15248..5d34f98b 100644 --- a/rust-bindings/src/repo.rs +++ b/rust-bindings/src/repo.rs @@ -72,6 +72,12 @@ pub struct TransactionGuard<'a> { } impl<'a> TransactionGuard<'a> { + /// Returns a reference to the repository. + pub fn repo(&self) -> &Repo { + // SAFETY: This is only set to None in `commit`, which consumes self + self.repo.unwrap() + } + /// Commit this transaction. pub fn commit>( mut self, diff --git a/rust-bindings/tests/util/mod.rs b/rust-bindings/tests/util/mod.rs index 472bf455..28cca926 100644 --- a/rust-bindings/tests/util/mod.rs +++ b/rust-bindings/tests/util/mod.rs @@ -67,7 +67,8 @@ pub fn commit(repo: &ostree::Repo, mtree: &ostree::MutableTree, ref_: &str) -> G let txn = repo .auto_transaction(NONE_CANCELLABLE) .expect("prepare transaction"); - let repo_file = repo + let repo_file = txn + .repo() .write_mtree(mtree, NONE_CANCELLABLE) .expect("write mtree") .downcast::()