mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-18 19:10:31 +08:00
Merge
* radicle-git improvements: publish: git-ref-format, radicle-git-ext, radicle-surf git-ref-format: add Refspec type commit: use read_header trailers: add Token constructor Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "radicle-git-ext"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
authors = [
|
||||
"Alexis Sellier <alexis@radicle.xyz>",
|
||||
"Kim Altintop <kim@eagain.st>",
|
||||
@@ -26,7 +26,7 @@ default-features = false
|
||||
features = ["vendored-libgit2"]
|
||||
|
||||
[dependencies.git-ref-format]
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
path = "./git-ref-format"
|
||||
features = ["macro", "serde", "minicbor"]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "git-ref-format"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = [
|
||||
"Kim Altintop <kim@eagain.st>",
|
||||
"Fintan Halpenny <fintan.halpenny@gmail.com>",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use std::{
|
||||
borrow::{Borrow, Cow},
|
||||
convert::TryFrom,
|
||||
fmt::{self, Display},
|
||||
fmt::{self, Display, Write as _},
|
||||
iter::FromIterator,
|
||||
ops::Deref,
|
||||
};
|
||||
@@ -558,3 +558,30 @@ impl Display for NamespacedPattern<'_> {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// A Git [refspec].
|
||||
///
|
||||
/// **Note** that this is a simplified version of a [refspec] where
|
||||
/// the `src` and `dst` are required and there is no way to construct
|
||||
/// a negative refspec, e.g. `^refs/heads/no-thanks`.
|
||||
///
|
||||
/// [refspec]: https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Refspec<T, U> {
|
||||
pub src: T,
|
||||
pub dst: U,
|
||||
pub force: bool,
|
||||
}
|
||||
|
||||
impl<T, U> fmt::Display for Refspec<T, U>
|
||||
where
|
||||
T: fmt::Display,
|
||||
U: fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.force {
|
||||
f.write_char('+')?;
|
||||
}
|
||||
write!(f, "{}:{}", self.src, self.dst)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ impl Commit {
|
||||
fn verify_object(odb: &git2::Odb, oid: &Oid, expected: ObjectType) -> Result<(), error::Write> {
|
||||
use git2::{Error, ErrorClass, ErrorCode};
|
||||
|
||||
let (_, _, kind) = odb
|
||||
.reader(*oid)
|
||||
let (_, kind) = odb
|
||||
.read_header(*oid)
|
||||
.map_err(|err| error::Write::OdbRead { oid: *oid, err })?;
|
||||
if kind != expected {
|
||||
Err(error::Write::NotCommit {
|
||||
|
||||
@@ -130,6 +130,19 @@ impl Deref for Token<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for Token<'a> {
|
||||
type Error = &'static str;
|
||||
|
||||
fn try_from(s: &'a str) -> Result<Self, Self::Error> {
|
||||
let is_token = s.chars().all(|c| c.is_alphanumeric() || c == '-');
|
||||
if is_token {
|
||||
Ok(Token(s))
|
||||
} else {
|
||||
Err("token contains invalid characters")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Display<'a> {
|
||||
trailer: &'a Trailer<'a>,
|
||||
separator: &'a str,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "radicle-surf"
|
||||
description = "A code surfing library for Git repositories"
|
||||
readme = "README.md"
|
||||
version = "0.10.1"
|
||||
version = "0.10.2"
|
||||
authors = ["The Radicle Team <dev@radicle.xyz>"]
|
||||
edition = "2021"
|
||||
homepage = "https://github.com/radicle-dev/radicle-surf"
|
||||
@@ -38,7 +38,7 @@ default-features = false
|
||||
features = ["vendored-libgit2"]
|
||||
|
||||
[dependencies.radicle-git-ext]
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
path = "../radicle-git-ext"
|
||||
features = ["serde"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user