repo: implement list_refs and list_refs_ext
This commit is contained in:
parent
ae9413343d
commit
dff1cf631b
|
|
@ -59,6 +59,7 @@ pub use self::enums::StaticDeltaGenerateOpt;
|
||||||
mod flags;
|
mod flags;
|
||||||
#[cfg(any(feature = "v2015_7", feature = "dox"))]
|
#[cfg(any(feature = "v2015_7", feature = "dox"))]
|
||||||
pub use self::flags::RepoCommitState;
|
pub use self::flags::RepoCommitState;
|
||||||
|
pub use self::flags::RepoListRefsExtFlags;
|
||||||
pub use self::flags::RepoPullFlags;
|
pub use self::flags::RepoPullFlags;
|
||||||
pub use self::flags::SePolicyRestoreconFlags;
|
pub use self::flags::SePolicyRestoreconFlags;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use auto::Repo;
|
use auto::{Repo, RepoListRefsExtFlags};
|
||||||
use ffi;
|
use ffi;
|
||||||
use gio;
|
use gio;
|
||||||
use glib;
|
use glib;
|
||||||
|
|
@ -6,7 +6,7 @@ use glib::Error;
|
||||||
use glib::IsA;
|
use glib::IsA;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib_ffi;
|
use glib_ffi;
|
||||||
use std::collections::HashSet;
|
use std::collections::{HashSet, HashMap};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use ObjectName;
|
use ObjectName;
|
||||||
|
|
@ -32,7 +32,19 @@ pub trait RepoExtManual {
|
||||||
&self,
|
&self,
|
||||||
commit_checksum: &str,
|
commit_checksum: &str,
|
||||||
maxdepth: i32,
|
maxdepth: i32,
|
||||||
cancellable: P) -> Result<HashSet<ObjectName>, Error>;
|
cancellable: P
|
||||||
|
) -> Result<HashSet<ObjectName>, Error>;
|
||||||
|
fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||||
|
&self,
|
||||||
|
refspec_prefix: P,
|
||||||
|
cancellable: Q
|
||||||
|
) -> Result<HashMap<String, String>, Error>;
|
||||||
|
fn list_refs_ext<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||||
|
&self,
|
||||||
|
refspec_prefix: P,
|
||||||
|
flags: RepoListRefsExtFlags,
|
||||||
|
cancellable: Q
|
||||||
|
) -> Result<HashMap<String, String>, Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
|
impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
|
||||||
|
|
@ -57,7 +69,61 @@ impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
|
||||||
cancellable.into().to_glib_none().0,
|
cancellable.into().to_glib_none().0,
|
||||||
&mut error,
|
&mut error,
|
||||||
);
|
);
|
||||||
if error.is_null() { Ok(from_glib_container_variant_set(hashtable)) } else { Err(from_glib_full(error)) }
|
if error.is_null() {
|
||||||
|
Ok(from_glib_container_variant_set(hashtable))
|
||||||
|
} else {
|
||||||
|
Err(from_glib_full(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_refs<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||||
|
&self,
|
||||||
|
refspec_prefix: P,
|
||||||
|
cancellable: Q
|
||||||
|
) -> Result<HashMap<String, String>, Error> {
|
||||||
|
unsafe {
|
||||||
|
let mut error = ptr::null_mut();
|
||||||
|
let mut hashtable = ptr::null_mut();
|
||||||
|
let _ = ffi::ostree_repo_list_refs(
|
||||||
|
self.to_glib_none().0,
|
||||||
|
refspec_prefix.into().to_glib_none().0,
|
||||||
|
&mut hashtable,
|
||||||
|
cancellable.into().to_glib_none().0,
|
||||||
|
&mut error,
|
||||||
|
);
|
||||||
|
|
||||||
|
if error.is_null() {
|
||||||
|
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
|
||||||
|
} else {
|
||||||
|
Err(from_glib_full(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_refs_ext<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gio::Cancellable>>>(
|
||||||
|
&self,
|
||||||
|
refspec_prefix: P,
|
||||||
|
flags: RepoListRefsExtFlags,
|
||||||
|
cancellable: Q
|
||||||
|
) -> Result<HashMap<String, String>, Error> {
|
||||||
|
unsafe {
|
||||||
|
let mut error = ptr::null_mut();
|
||||||
|
let mut hashtable = ptr::null_mut();
|
||||||
|
let _ = ffi::ostree_repo_list_refs_ext(
|
||||||
|
self.to_glib_none().0,
|
||||||
|
refspec_prefix.into().to_glib_none().0,
|
||||||
|
&mut hashtable,
|
||||||
|
flags.to_glib(),
|
||||||
|
cancellable.into().to_glib_none().0,
|
||||||
|
&mut error,
|
||||||
|
);
|
||||||
|
|
||||||
|
if error.is_null() {
|
||||||
|
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
|
||||||
|
} else {
|
||||||
|
Err(from_glib_full(error))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,13 @@ use libostree::prelude::*;
|
||||||
fn main() {
|
fn main() {
|
||||||
let repo = libostree::Repo::new_for_path("../../../repo-bare");
|
let repo = libostree::Repo::new_for_path("../../../repo-bare");
|
||||||
|
|
||||||
//let result = repo.create(libostree::RepoMode::Archive, Option::None);
|
|
||||||
//result.expect("we did not expect this to fail :O");
|
|
||||||
|
|
||||||
repo.open(None).expect("should have opened");
|
repo.open(None).expect("should have opened");
|
||||||
|
|
||||||
|
let refs = repo.list_refs(None, None).unwrap();
|
||||||
|
for (refspec, checksum) in refs {
|
||||||
|
println!(" {} = {}", refspec, checksum);
|
||||||
|
}
|
||||||
|
|
||||||
let (file, checksum) = repo.read_commit("test", None).unwrap();
|
let (file, checksum) = repo.read_commit("test", None).unwrap();
|
||||||
|
|
||||||
println!("path: {:?}", file.get_path());
|
println!("path: {:?}", file.get_path());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue