Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Various small improvements across crates
Browse files Browse the repository at this point in the history
Most of these changes should be self-explanatory.

* Atomic fetch was no longer used
* The default policy when initializing should be 'all', as it is with
  `rad init`.
  • Loading branch information
cloudhead committed Feb 6, 2024
1 parent bb06663 commit 98c94de
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
5 changes: 5 additions & 0 deletions radicle-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ impl PublicKey {
refname!("refs/namespaces").join(Component::from(self))
}

#[cfg(feature = "radicle-git-ext")]
pub fn to_component(&self) -> radicle_git_ext::ref_format::Component {
radicle_git_ext::ref_format::Component::from(self)
}

#[cfg(feature = "radicle-git-ext")]
pub fn from_namespaced(
refstr: &radicle_git_ext::ref_format::Namespaced,
Expand Down
8 changes: 0 additions & 8 deletions radicle-node/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ impl Runtime {
}
let reactor = Reactor::named(wire, popol::Poller::new(), thread::name(&id, "service"))?;
let handle = Handle::new(home.clone(), reactor.controller(), emitter);
let atomic = git::version()? >= git::VERSION_REQUIRED;

if !atomic {
log::warn!(
target: "node",
"Disabling atomic fetches; git version >= {} required", git::VERSION_REQUIRED
);
}

let nid = *signer.public_key();
let fetch = worker::FetchConfig {
Expand Down
5 changes: 1 addition & 4 deletions radicle-node/src/test/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,7 @@ impl<G: cyphernet::Ecdh<Pk = NodeId> + Signer + Clone> Node<G> {
.map(|(id, _, _)| id)
.unwrap();

assert!(self
.policies
.seed(&id, node::policy::Scope::Followed)
.unwrap());
assert!(self.policies.seed(&id, node::policy::Scope::All).unwrap());

log::debug!(
target: "test",
Expand Down
7 changes: 6 additions & 1 deletion radicle/src/cob/issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ impl IssueCounts {
}
}

impl<'a, R: WriteRepository> Issues<'a, R>
impl<'a, R> Issues<'a, R>
where
R: ReadRepository + cob::Store,
{
Expand All @@ -699,7 +699,12 @@ where

Ok(Self { raw })
}
}

impl<'a, R> Issues<'a, R>
where
R: WriteRepository + cob::Store,
{
/// Get an issue.
pub fn get(&self, id: &ObjectId) -> Result<Option<Issue>, store::Error> {
self.raw.get(id)
Expand Down
2 changes: 1 addition & 1 deletion radicle/src/cob/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ impl<'a, R> Deref for Patches<'a, R> {

impl<'a, R> Patches<'a, R>
where
R: ReadRepository + cob::Store + 'static,
R: ReadRepository + cob::Store,
{
/// Open a patches store.
pub fn open(repository: &'a R) -> Result<Self, RepositoryError> {
Expand Down
2 changes: 1 addition & 1 deletion radicle/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl FetchResult {
}
}

pub fn find_updated(&self, name: &git::RefString) -> Option<RefUpdate> {
pub fn find_updated(&self, name: &git::RefStr) -> Option<RefUpdate> {
let updated = match self {
Self::Success { updated, .. } => Some(updated),
_ => None,
Expand Down
36 changes: 29 additions & 7 deletions radicle/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use radicle_git_ext::Oid;
use crate::cob;
use crate::collections::RandomMap;
use crate::git::ext as git_ext;
use crate::git::{refspec::Refspec, PatternString, Qualified, RefError, RefString};
use crate::git::{refspec::Refspec, PatternString, Qualified, RefError, RefStr, RefString};
use crate::identity::{Did, PayloadError};
use crate::identity::{Doc, DocAt, DocError};
use crate::identity::{Identity, RepoId};
Expand Down Expand Up @@ -186,12 +186,34 @@ impl RefUpdate {
}
}

pub fn name(&self) -> &RefString {
match &self {
RefUpdate::Updated { name, .. } => name,
RefUpdate::Created { name, .. } => name,
RefUpdate::Deleted { name, .. } => name,
RefUpdate::Skipped { name, .. } => name,
/// Get the old OID, if any.
pub fn old(&self) -> Option<Oid> {
match self {
RefUpdate::Updated { old, .. } => Some(*old),
RefUpdate::Created { .. } => None,
RefUpdate::Deleted { oid, .. } => Some(*oid),
RefUpdate::Skipped { oid, .. } => Some(*oid),
}
}

/// Get the new OID, if any.
#[allow(clippy::new_ret_no_self)]
pub fn new(&self) -> Option<Oid> {
match self {
RefUpdate::Updated { new, .. } => Some(*new),
RefUpdate::Created { oid, .. } => Some(*oid),
RefUpdate::Deleted { .. } => None,
RefUpdate::Skipped { .. } => None,
}
}

/// Get the ref name.
pub fn name(&self) -> &RefStr {
match self {
RefUpdate::Updated { name, .. } => name.as_refstr(),
RefUpdate::Created { name, .. } => name.as_refstr(),
RefUpdate::Deleted { name, .. } => name.as_refstr(),
RefUpdate::Skipped { name, .. } => name.as_refstr(),
}
}
}
Expand Down

0 comments on commit 98c94de

Please sign in to comment.