Regenerate and update to new gir and glib-rs version
This commit is contained in:
1 parent
df2d708f30
commit
61e205b5c3
28 files changed
+1985
-2618
No files matched your search
@@ -3,15 +3,17 @@ extern crate glib;
|
||||
extern crate ostree;
|
||||
extern crate tempfile;
|
||||
|
||||
use gio::NONE_CANCELLABLE;
|
||||
use glib::prelude::*;
|
||||
use ostree::prelude::*;
|
||||
use ostree::RepoFile;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
fn create_repo(repodir: &tempfile::TempDir) -> Result<ostree::Repo, glib::Error> {
|
||||
let repo = ostree::Repo::new_for_path(repodir.path());
|
||||
repo.create(ostree::RepoMode::Archive, None)?;
|
||||
repo.create(ostree::RepoMode::Archive, NONE_CANCELLABLE)?;
|
||||
Ok(repo)
|
||||
}
|
||||
|
||||
@@ -27,25 +29,34 @@ fn create_mtree(
|
||||
) -> Result<ostree::MutableTree, glib::Error> {
|
||||
let gfile = gio::File::new_for_path(treedir.path());
|
||||
let mtree = ostree::MutableTree::new();
|
||||
repo.write_directory_to_mtree(&gfile, &mtree, None, None)?;
|
||||
repo.write_directory_to_mtree(&gfile, &mtree, None, NONE_CANCELLABLE)?;
|
||||
Ok(mtree)
|
||||
}
|
||||
|
||||
fn commit_mtree(
|
||||
repo: &ostree::Repo,
|
||||
mtree: &ostree::MutableTree,
|
||||
) -> Result<String, glib::Error> {
|
||||
repo.prepare_transaction(None)?;
|
||||
let repo_file = repo.write_mtree(mtree, None)?.downcast().unwrap();
|
||||
let checksum = repo.write_commit(None, "Test Commit", None, None, &repo_file, None)?;
|
||||
repo.transaction_set_ref(None, "test", checksum.as_str());
|
||||
repo.commit_transaction(None)?;
|
||||
fn commit_mtree(repo: &ostree::Repo, mtree: &ostree::MutableTree) -> Result<String, glib::Error> {
|
||||
repo.prepare_transaction(NONE_CANCELLABLE)?;
|
||||
let repo_file = repo
|
||||
.write_mtree(mtree, NONE_CANCELLABLE)?
|
||||
.downcast::<RepoFile>()
|
||||
.unwrap();
|
||||
let checksum = repo
|
||||
.write_commit(
|
||||
None,
|
||||
"Test Commit".into(),
|
||||
None,
|
||||
None,
|
||||
&repo_file,
|
||||
NONE_CANCELLABLE,
|
||||
)?
|
||||
.to_string();
|
||||
repo.transaction_set_ref(None, "test", checksum.as_str().into());
|
||||
repo.commit_transaction(NONE_CANCELLABLE)?;
|
||||
Ok(checksum)
|
||||
}
|
||||
|
||||
fn open_repo(repodir: &tempfile::TempDir) -> Result<ostree::Repo, glib::Error> {
|
||||
let repo = ostree::Repo::new_for_path(repodir.path());
|
||||
repo.open(None)?;
|
||||
repo.open(NONE_CANCELLABLE)?;
|
||||
Ok(repo)
|
||||
}
|
||||
|
||||
@@ -60,7 +71,9 @@ fn should_commit_content_to_repo_and_list_refs_again() {
|
||||
let checksum = commit_mtree(&repo, &mtree).expect("failed to commit mtree");
|
||||
|
||||
let repo = open_repo(&repodir).expect("failed to open repo");
|
||||
let refs = repo.list_refs(None, None).expect("failed to list refs");
|
||||
let refs = repo
|
||||
.list_refs(None, NONE_CANCELLABLE)
|
||||
.expect("failed to list refs");
|
||||
assert_eq!(refs.len(), 1);
|
||||
assert_eq!(refs["test"], checksum);
|
||||
}
|
||||
Reference in new issue
Block a user