Run cargo fmt on the custom code
This commit is contained in:
parent
fdac646f7e
commit
88b4a12c32
|
|
@ -1,7 +1,7 @@
|
|||
extern crate libostree_sys as ffi;
|
||||
extern crate gio_sys as gio_ffi;
|
||||
extern crate glib_sys as glib_ffi;
|
||||
extern crate gobject_sys as gobject_ffi;
|
||||
extern crate gio_sys as gio_ffi;
|
||||
extern crate libostree_sys as ffi;
|
||||
#[macro_use]
|
||||
extern crate glib;
|
||||
extern crate gio;
|
||||
|
|
@ -15,8 +15,8 @@ use glib::Error;
|
|||
|
||||
// re-exports
|
||||
mod auto;
|
||||
pub use auto::*;
|
||||
pub use auto::functions::*;
|
||||
pub use auto::*;
|
||||
|
||||
mod repo;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ use functions::{object_name_deserialize, object_name_serialize, object_to_string
|
|||
use glib;
|
||||
use glib::translate::*;
|
||||
use glib_ffi;
|
||||
use ObjectType;
|
||||
use std::fmt::Display;
|
||||
use std::fmt::Error;
|
||||
use std::fmt::Formatter;
|
||||
use std::hash::Hash;
|
||||
use std::hash::Hasher;
|
||||
use ObjectType;
|
||||
|
||||
fn hash_object_name(v: &glib::Variant) -> u32 {
|
||||
unsafe { ffi::ostree_hash_object_name(v.to_glib_none().0 as glib_ffi::gconstpointer) }
|
||||
|
|
|
|||
|
|
@ -2,30 +2,36 @@ use auto::{Repo, RepoListRefsExtFlags};
|
|||
use ffi;
|
||||
use gio;
|
||||
use glib;
|
||||
use glib::translate::*;
|
||||
use glib::Error;
|
||||
use glib::IsA;
|
||||
use glib::translate::*;
|
||||
use glib_ffi;
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use std::ptr;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::Path;
|
||||
use std::ptr;
|
||||
use ObjectName;
|
||||
|
||||
unsafe extern "C" fn read_variant_table(_key: glib_ffi::gpointer, value: glib_ffi::gpointer, hash_set: glib_ffi::gpointer) {
|
||||
unsafe extern "C" fn read_variant_table(
|
||||
_key: glib_ffi::gpointer,
|
||||
value: glib_ffi::gpointer,
|
||||
hash_set: glib_ffi::gpointer,
|
||||
) {
|
||||
let value: glib::Variant = from_glib_none(value as *const glib_ffi::GVariant);
|
||||
let set: &mut HashSet<ObjectName> = &mut *(hash_set as *mut HashSet<ObjectName>);
|
||||
set.insert(ObjectName::new_from_variant(value));
|
||||
}
|
||||
|
||||
|
||||
unsafe fn from_glib_container_variant_set(ptr: *mut glib_ffi::GHashTable) -> HashSet<ObjectName> {
|
||||
let mut set = HashSet::new();
|
||||
glib_ffi::g_hash_table_foreach(ptr, Some(read_variant_table), &mut set as *mut HashSet<ObjectName> as *mut _);
|
||||
glib_ffi::g_hash_table_foreach(
|
||||
ptr,
|
||||
Some(read_variant_table),
|
||||
&mut set as *mut HashSet<ObjectName> as *mut _,
|
||||
);
|
||||
glib_ffi::g_hash_table_unref(ptr);
|
||||
set
|
||||
}
|
||||
|
||||
|
||||
pub trait RepoExtManual {
|
||||
fn new_for_path<P: AsRef<Path>>(path: P) -> Repo;
|
||||
|
||||
|
|
@ -53,7 +59,7 @@ pub trait RepoExtManual {
|
|||
&self,
|
||||
commit_checksum: &str,
|
||||
maxdepth: i32,
|
||||
cancellable: P
|
||||
cancellable: P,
|
||||
) -> Result<HashSet<ObjectName>, Error>;
|
||||
|
||||
/// If `refspec_prefix` is `None`, list all local and remote refspecs,
|
||||
|
|
@ -87,7 +93,7 @@ pub trait RepoExtManual {
|
|||
fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||
&self,
|
||||
refspec_prefix: P,
|
||||
cancellable: Q
|
||||
cancellable: Q,
|
||||
) -> Result<HashMap<String, String>, Error>;
|
||||
|
||||
/// If `refspec_prefix` is `None`, list all local and remote refspecs,
|
||||
|
|
@ -126,7 +132,7 @@ pub trait RepoExtManual {
|
|||
&self,
|
||||
refspec_prefix: P,
|
||||
flags: RepoListRefsExtFlags,
|
||||
cancellable: Q
|
||||
cancellable: Q,
|
||||
) -> Result<HashMap<String, String>, Error>;
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +169,7 @@ impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
|
|||
fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||
&self,
|
||||
refspec_prefix: P,
|
||||
cancellable: Q
|
||||
cancellable: Q,
|
||||
) -> Result<HashMap<String, String>, Error> {
|
||||
unsafe {
|
||||
let mut error = ptr::null_mut();
|
||||
|
|
@ -188,7 +194,7 @@ impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
|
|||
&self,
|
||||
refspec_prefix: P,
|
||||
flags: RepoListRefsExtFlags,
|
||||
cancellable: Q
|
||||
cancellable: Q,
|
||||
) -> Result<HashMap<String, String>, Error> {
|
||||
unsafe {
|
||||
let mut error = ptr::null_mut();
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ extern crate glib;
|
|||
extern crate libostree;
|
||||
extern crate tempfile;
|
||||
|
||||
use glib::prelude::*;
|
||||
use libostree::prelude::*;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use glib::prelude::*;
|
||||
use libostree::prelude::*;
|
||||
|
||||
|
||||
|
||||
fn create_repo(repodir: &tempfile::TempDir) -> Result<libostree::Repo, glib::Error> {
|
||||
let repo = libostree::Repo::new_for_path(repodir.path());
|
||||
|
|
@ -23,14 +21,20 @@ fn create_test_file(treedir: &tempfile::TempDir) -> Result<(), io::Error> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn create_mtree(treedir: &tempfile::TempDir, repo: &libostree::Repo) -> Result<libostree::MutableTree, glib::Error> {
|
||||
fn create_mtree(
|
||||
treedir: &tempfile::TempDir,
|
||||
repo: &libostree::Repo,
|
||||
) -> Result<libostree::MutableTree, glib::Error> {
|
||||
let gfile = gio::File::new_for_path(treedir.path());
|
||||
let mtree = libostree::MutableTree::new();
|
||||
repo.write_directory_to_mtree(&gfile, &mtree, None, None)?;
|
||||
Ok(mtree)
|
||||
}
|
||||
|
||||
fn commit_mtree(repo: &libostree::Repo, mtree: &libostree::MutableTree) -> Result<String, glib::Error> {
|
||||
fn commit_mtree(
|
||||
repo: &libostree::Repo,
|
||||
mtree: &libostree::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)?;
|
||||
|
|
@ -56,8 +60,7 @@ 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).expect("failed to list refs");
|
||||
assert_eq!(refs.len(), 1);
|
||||
assert_eq!(refs["test"], checksum);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue