Skip to content

Commit

Permalink
Merge pull request #54 from ostreedev/txn-guard-repo
Browse files Browse the repository at this point in the history
Add a `repo()` accessor to `TransactionGuard`
  • Loading branch information
cgwalters authored Apr 27, 2022
2 parents 5c1e887 + b42b0ad commit d7c99eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: IsA<gio::Cancellable>>(
mut self,
Expand Down
3 changes: 2 additions & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ostree::RepoFile>()
Expand Down

0 comments on commit d7c99eb

Please sign in to comment.