Test canonical refs are set
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
parent
e6fd85f249
commit
961c18319f
|
|
@ -18,7 +18,9 @@ pub use ext::NotFound;
|
|||
pub use ext::Oid;
|
||||
pub use git2 as raw;
|
||||
pub use git_ref_format as fmt;
|
||||
pub use git_ref_format::{lit, name, refname, Component, Namespaced, Qualified, RefStr, RefString};
|
||||
pub use git_ref_format::{
|
||||
lit, name, qualified, refname, Component, Namespaced, Qualified, RefStr, RefString,
|
||||
};
|
||||
pub use git_url as url;
|
||||
pub use git_url::Url;
|
||||
pub use radicle_git_ext as ext;
|
||||
|
|
|
|||
|
|
@ -352,6 +352,19 @@ mod tests {
|
|||
.collect::<Result<_, _>>()
|
||||
.unwrap();
|
||||
|
||||
let project_repo = storage.repository(proj).unwrap();
|
||||
let (head, _) = project_repo.head().unwrap();
|
||||
|
||||
// Test canonical refs.
|
||||
assert_eq!(project_repo.raw().refname_to_id("HEAD").unwrap(), *head);
|
||||
assert_eq!(
|
||||
project_repo
|
||||
.raw()
|
||||
.refname_to_id("refs/heads/master")
|
||||
.unwrap(),
|
||||
*head
|
||||
);
|
||||
|
||||
assert_eq!(remotes[&public_key].refs, refs);
|
||||
assert_eq!(project.name, "acme");
|
||||
assert_eq!(project.description, "Acme's repo");
|
||||
|
|
|
|||
|
|
@ -424,6 +424,17 @@ impl ReadRepository for Repository {
|
|||
self.backend.find_reference(&name).map_err(git::Error::from)
|
||||
}
|
||||
|
||||
fn reference_oid(
|
||||
&self,
|
||||
remote: &RemoteId,
|
||||
reference: &git::Qualified,
|
||||
) -> Result<Oid, git::Error> {
|
||||
let name = reference.with_namespace(remote.into());
|
||||
let oid = self.backend.refname_to_id(&name)?;
|
||||
|
||||
Ok(oid.into())
|
||||
}
|
||||
|
||||
fn commit(&self, oid: Oid) -> Result<git2::Commit, git::Error> {
|
||||
self.backend
|
||||
.find_commit(oid.into())
|
||||
|
|
@ -437,17 +448,6 @@ impl ReadRepository for Repository {
|
|||
Ok(revwalk)
|
||||
}
|
||||
|
||||
fn reference_oid(
|
||||
&self,
|
||||
remote: &RemoteId,
|
||||
reference: &git::Qualified,
|
||||
) -> Result<Oid, git::Error> {
|
||||
let name = reference.with_namespace(remote.into());
|
||||
let oid = self.backend.refname_to_id(&name)?;
|
||||
|
||||
Ok(oid.into())
|
||||
}
|
||||
|
||||
fn remote(&self, remote: &RemoteId) -> Result<Remote<Verified>, refs::Error> {
|
||||
let refs = SignedRefs::load(remote, self)?;
|
||||
Ok(Remote::new(*remote, refs))
|
||||
|
|
|
|||
Loading…
Reference in New Issue