lib: Move to cob cache

This commit is contained in:
Erik Kundt
2024-02-26 15:00:09 +01:00
parent ee8a14de52
commit 6cbca9401f
7 changed files with 48 additions and 39 deletions
Generated
+6 -6
View File
@@ -1473,7 +1473,7 @@ dependencies = [
[[package]]
name = "radicle"
version = "0.2.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"amplify",
"base64 0.21.7",
@@ -1503,7 +1503,7 @@ dependencies = [
[[package]]
name = "radicle-cob"
version = "0.2.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"fastrand",
"git2",
@@ -1521,7 +1521,7 @@ dependencies = [
[[package]]
name = "radicle-crypto"
version = "0.2.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"amplify",
"cyphernet",
@@ -1539,7 +1539,7 @@ dependencies = [
[[package]]
name = "radicle-dag"
version = "0.2.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"fastrand",
]
@@ -1561,7 +1561,7 @@ dependencies = [
[[package]]
name = "radicle-ssh"
version = "0.2.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"byteorder",
"log",
@@ -1596,7 +1596,7 @@ dependencies = [
[[package]]
name = "radicle-term"
version = "0.1.0"
source = "git+https://github.com/radicle-dev/heartwood?rev=eff4016#eff40166c9ac8ad9776ecb6160d245220bfb1f87"
source = "git+https://github.com/radicle-dev/heartwood#09f2befa58dc6057e052904b6947bdd17d3b0553"
dependencies = [
"anstyle-query",
"anyhow",
+2 -2
View File
@@ -21,8 +21,8 @@ inquire = { version = "0.6.2", default-features = false, features = ["termion",
lexopt = { version = "0.3.0" }
libc = { version = "^0.2" }
log = { version = "0.4.19" }
radicle = { git = "https://github.com/radicle-dev/heartwood", rev = "eff4016" }
radicle-term = { git = "https://github.com/radicle-dev/heartwood", package = "radicle-term", rev = "eff4016" }
radicle = { git = "https://github.com/radicle-dev/heartwood" }
radicle-term = { git = "https://github.com/radicle-dev/heartwood", package = "radicle-term" }
radicle-surf = { version = "0.18.0" }
ratatui = { git = "https://github.com/erak/ratatui", branch = "termion-cursor", default-features = false, features = ["all-widgets", "termion"] }
simple-logging = { version = "2.0.2" }
+1 -1
View File
@@ -45,7 +45,7 @@ impl TryFrom<&Context> for IssuesState {
type Error = anyhow::Error;
fn try_from(context: &Context) -> Result<Self, Self::Error> {
let issues = issue::all(&context.repository)?;
let issues = issue::all(&context.profile, &context.repository)?;
let issues = issues
.iter()
.filter(|(_, issue)| context.filter.matches(&context.profile, issue));
+1 -1
View File
@@ -45,7 +45,7 @@ impl TryFrom<&Context> for PatchesState {
type Error = anyhow::Error;
fn try_from(context: &Context) -> Result<Self, Self::Error> {
let patches = patch::all(&context.repository)?;
let patches = patch::all(&context.profile, &context.repository)?;
let patches = patches
.iter()
.filter(|(_, patch)| context.filter.matches(&context.profile, patch));
+18 -13
View File
@@ -1,8 +1,9 @@
use std::fmt::Display;
use anyhow::Result;
use radicle::cob::issue::{Issue, IssueId, Issues};
use radicle::cob::issue::{Issue, IssueId};
use radicle::cob::Label;
use radicle::issue::cache::Issues;
use radicle::issue::CloseReason;
use radicle::prelude::{Did, Signer};
use radicle::storage::git::Repository;
@@ -118,23 +119,27 @@ impl ToString for Filter {
}
}
pub fn all(repository: &Repository) -> Result<Vec<(IssueId, Issue)>> {
let patches = Issues::open(repository)?
.all()
.map(|iter| iter.flatten().collect::<Vec<_>>())?;
pub fn all(profile: &Profile, repository: &Repository) -> Result<Vec<(IssueId, Issue)>> {
let cache = profile.issues(repository)?;
let issues = cache.list()?;
let mut all = vec![];
for issue in issues {
if let Ok((id, issue)) = issue {
all.push((id, issue))
}
}
Ok(patches
.into_iter()
.map(|(id, issue)| (id, issue))
.collect::<Vec<_>>())
Ok(all)
}
pub fn find(repository: &Repository, id: &IssueId) -> Result<Option<Issue>> {
let issues = Issues::open(repository)?;
Ok(issues.get(id)?)
pub fn find(profile: &Profile, repository: &Repository, id: &IssueId) -> Result<Option<Issue>> {
let cache = profile.issues(repository)?;
Ok(cache.get(id)?)
}
pub fn create<G: Signer>(
profile: &Profile,
repository: &Repository,
signer: &G,
title: String,
@@ -142,7 +147,7 @@ pub fn create<G: Signer>(
labels: &[Label],
assignees: &[Did],
) -> Result<IssueId> {
let mut issues = Issues::open(repository)?;
let mut issues = profile.issues_mut(repository)?;
let issue = issues.create(title, description.trim(), labels, assignees, [], signer)?;
Ok(*issue.id())
+16 -12
View File
@@ -2,8 +2,9 @@ use std::fmt::Display;
use anyhow::Result;
use radicle::cob::patch::{Patch, PatchId, Patches};
use radicle::cob::patch::{Patch, PatchId};
use radicle::identity::Did;
use radicle::patch::cache::Patches;
use radicle::storage::git::Repository;
use radicle::{patch, Profile};
@@ -110,18 +111,21 @@ impl ToString for Filter {
}
}
pub fn all(repository: &Repository) -> Result<Vec<(PatchId, Patch)>> {
let patches = Patches::open(repository)?
.all()
.map(|iter| iter.flatten().collect::<Vec<_>>())?;
pub fn all(profile: &Profile, repository: &Repository) -> Result<Vec<(PatchId, Patch)>> {
let cache = profile.patches(repository)?;
let patches = cache.list()?;
Ok(patches
.into_iter()
.map(|(id, patch)| (id, patch))
.collect::<Vec<_>>())
let mut all = vec![];
for patch in patches {
if let Ok((id, patch)) = patch {
all.push((id, patch))
}
}
Ok(all)
}
pub fn find(repository: &Repository, id: &PatchId) -> Result<Option<Patch>> {
let patches = Patches::open(repository)?;
Ok(patches.get(id)?)
pub fn find(profile: &Profile, repository: &Repository, id: &PatchId) -> Result<Option<Patch>> {
let cache = profile.patches(repository)?;
Ok(cache.get(id)?)
}
+4 -4
View File
@@ -71,13 +71,13 @@ impl Context {
pub fn with_issues(mut self) -> Self {
use super::cob::issue;
self.issues = Some(issue::all(&self.repository).unwrap_or_default());
self.issues = Some(issue::all(&self.profile, &self.repository).unwrap_or_default());
self
}
pub fn with_patches(mut self) -> Self {
use super::cob::patch;
self.patches = Some(patch::all(&self.repository).unwrap_or_default());
self.patches = Some(patch::all(&self.profile, &self.repository).unwrap_or_default());
self
}
@@ -121,12 +121,12 @@ impl Context {
pub fn reload_patches(&mut self) {
use super::cob::patch;
self.patches = Some(patch::all(&self.repository).unwrap_or_default());
self.patches = Some(patch::all(&self.profile, &self.repository).unwrap_or_default());
}
pub fn reload_issues(&mut self) {
use super::cob::issue;
self.issues = Some(issue::all(&self.repository).unwrap_or_default());
self.issues = Some(issue::all(&self.profile, &self.repository).unwrap_or_default());
}
}