Files
radicle-git/git-ext/src/reference.rs
T
Fintan Halpenny 70b571b67b radicle-git init
Port over all git relevant parts of the radicle-link repository[0].
The packages that are kept are:
* git-ext
* git-ref-format
* git-trailers
* link-git
* macros
* std-ext
* test -- only the portions that test the above

The development and testing scripts are also added for local and CI
testing.

[0]: https://github.com/radicle-dev/radicle-link/
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-08 12:07:51 +01:00

27 lines
840 B
Rust

// Copyright © 2019-2020 The Radicle Foundation <hello@radicle.foundation>
//
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
// Linking Exception. For full terms see the included LICENSE file.
use std::convert::TryFrom as _;
mod iter;
pub use iter::{ReferenceNames, References};
pub mod name;
pub use name::{OneLevel, Qualified, RefLike, RefspecPattern};
pub mod check {
pub use git_ref_format::{check_ref_format as ref_format, Error, Options};
}
pub fn peeled(head: git2::Reference) -> Option<(String, git2::Oid)> {
head.name()
.and_then(|name| head.target().map(|target| (name.to_owned(), target)))
}
pub fn refined((name, oid): (&str, git2::Oid)) -> Result<(OneLevel, crate::Oid), name::Error> {
let name = RefLike::try_from(name)?;
Ok((OneLevel::from(name), oid.into()))
}