Various small improvements across crates

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`.
This commit is contained in:
cloudhead 2024-02-02 16:46:20 +01:00
parent bb06663d1c
commit 98c94de5e3
No known key found for this signature in database
7 changed files with 43 additions and 22 deletions

View File

@ -354,6 +354,11 @@ impl PublicKey {
refname!("refs/namespaces").join(Component::from(self)) 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")] #[cfg(feature = "radicle-git-ext")]
pub fn from_namespaced( pub fn from_namespaced(
refstr: &radicle_git_ext::ref_format::Namespaced, refstr: &radicle_git_ext::ref_format::Namespaced,

View File

@ -240,14 +240,6 @@ impl Runtime {
} }
let reactor = Reactor::named(wire, popol::Poller::new(), thread::name(&id, "service"))?; let reactor = Reactor::named(wire, popol::Poller::new(), thread::name(&id, "service"))?;
let handle = Handle::new(home.clone(), reactor.controller(), emitter); 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 nid = *signer.public_key();
let fetch = worker::FetchConfig { let fetch = worker::FetchConfig {

View File

@ -476,10 +476,7 @@ impl<G: cyphernet::Ecdh<Pk = NodeId> + Signer + Clone> Node<G> {
.map(|(id, _, _)| id) .map(|(id, _, _)| id)
.unwrap(); .unwrap();
assert!(self assert!(self.policies.seed(&id, node::policy::Scope::All).unwrap());
.policies
.seed(&id, node::policy::Scope::Followed)
.unwrap());
log::debug!( log::debug!(
target: "test", target: "test",

View File

@ -688,7 +688,7 @@ impl IssueCounts {
} }
} }
impl<'a, R: WriteRepository> Issues<'a, R> impl<'a, R> Issues<'a, R>
where where
R: ReadRepository + cob::Store, R: ReadRepository + cob::Store,
{ {
@ -699,7 +699,12 @@ where
Ok(Self { raw }) Ok(Self { raw })
} }
}
impl<'a, R> Issues<'a, R>
where
R: WriteRepository + cob::Store,
{
/// Get an issue. /// Get an issue.
pub fn get(&self, id: &ObjectId) -> Result<Option<Issue>, store::Error> { pub fn get(&self, id: &ObjectId) -> Result<Option<Issue>, store::Error> {
self.raw.get(id) self.raw.get(id)

View File

@ -2241,7 +2241,7 @@ impl<'a, R> Deref for Patches<'a, R> {
impl<'a, R> Patches<'a, R> impl<'a, R> Patches<'a, R>
where where
R: ReadRepository + cob::Store + 'static, R: ReadRepository + cob::Store,
{ {
/// Open a patches store. /// Open a patches store.
pub fn open(repository: &'a R) -> Result<Self, RepositoryError> { pub fn open(repository: &'a R) -> Result<Self, RepositoryError> {

View File

@ -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 { let updated = match self {
Self::Success { updated, .. } => Some(updated), Self::Success { updated, .. } => Some(updated),
_ => None, _ => None,

View File

@ -17,7 +17,7 @@ pub use radicle_git_ext::Oid;
use crate::cob; use crate::cob;
use crate::collections::RandomMap; use crate::collections::RandomMap;
use crate::git::ext as git_ext; 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::{Did, PayloadError};
use crate::identity::{Doc, DocAt, DocError}; use crate::identity::{Doc, DocAt, DocError};
use crate::identity::{Identity, RepoId}; use crate::identity::{Identity, RepoId};
@ -186,12 +186,34 @@ impl RefUpdate {
} }
} }
pub fn name(&self) -> &RefString { /// Get the old OID, if any.
match &self { pub fn old(&self) -> Option<Oid> {
RefUpdate::Updated { name, .. } => name, match self {
RefUpdate::Created { name, .. } => name, RefUpdate::Updated { old, .. } => Some(*old),
RefUpdate::Deleted { name, .. } => name, RefUpdate::Created { .. } => None,
RefUpdate::Skipped { name, .. } => name, 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(),
} }
} }
} }