mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Remove unused patch read commands and diff helper
`revision_by_patch_and_id` and `review_by_patch_and_revision_and_id` were registered as Tauri commands but never invoked: the patch view resolves a revision or review from the revisions it already holds. Drop the commands, their registrations and the `revision_by_id` / `review_by_id` port methods, which had no other callers. `fileDiffName` in `diffText` has had no callers since it was added.
This commit is contained in:
@@ -2,7 +2,7 @@ use std::ops::ControlFlow;
|
||||
|
||||
use radicle::patch::{ReviewId, TYPENAME};
|
||||
use radicle::storage::{ReadRepository as _, ReadStorage};
|
||||
use radicle::{cob, git, identity};
|
||||
use radicle::{git, identity};
|
||||
|
||||
use radicle_types as types;
|
||||
use radicle_types::cobs;
|
||||
@@ -53,27 +53,6 @@ pub fn revisions_by_patch(
|
||||
ctx.revisions_by_patch(rid, id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn revision_by_patch_and_id(
|
||||
ctx: tauri::State<AppState>,
|
||||
rid: identity::RepoId,
|
||||
id: git::Oid,
|
||||
revision_id: git::Oid,
|
||||
) -> Result<Option<models::patch::Revision>, Error> {
|
||||
ctx.revision_by_id(rid, id, revision_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn review_by_patch_and_revision_and_id(
|
||||
ctx: tauri::State<AppState>,
|
||||
rid: identity::RepoId,
|
||||
id: git::Oid,
|
||||
revision_id: git::Oid,
|
||||
review_id: cob::patch::ReviewId,
|
||||
) -> Result<Option<models::patch::Review>, Error> {
|
||||
ctx.review_by_id(rid, id, revision_id, review_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn edit_patch(
|
||||
ctx: tauri::State<AppState>,
|
||||
|
||||
@@ -49,9 +49,7 @@ pub fn run() {
|
||||
cob::patch::patch_by_id,
|
||||
cob::patch::create_patch_review,
|
||||
cob::patch::rebuild_patch_cache,
|
||||
cob::patch::review_by_patch_and_revision_and_id,
|
||||
cob::patch::revisions_by_patch,
|
||||
cob::patch::revision_by_patch_and_id,
|
||||
cob::patch::revisions_by_patch,
|
||||
cob::save_embed_by_bytes,
|
||||
cob::save_embed_by_clipboard,
|
||||
|
||||
@@ -48,48 +48,6 @@ pub trait Patches: Profile {
|
||||
|
||||
Ok::<_, Error>(revisions)
|
||||
}
|
||||
|
||||
fn revision_by_id(
|
||||
&self,
|
||||
rid: identity::RepoId,
|
||||
id: git::Oid,
|
||||
revision_id: git::Oid,
|
||||
) -> Result<Option<models::patch::Revision>, Error> {
|
||||
let profile = self.profile();
|
||||
let repo = profile.storage.repository(rid)?;
|
||||
let patches = profile.patches(&repo)?;
|
||||
let revision = patches.get(&id.into())?.and_then(|patch| {
|
||||
let aliases = &profile.aliases();
|
||||
|
||||
patch
|
||||
.revision(&revision_id.into())
|
||||
.map(|r| models::patch::Revision::new(r.clone(), aliases))
|
||||
});
|
||||
|
||||
Ok::<_, Error>(revision)
|
||||
}
|
||||
|
||||
fn review_by_id(
|
||||
&self,
|
||||
rid: identity::RepoId,
|
||||
id: git::Oid,
|
||||
revision_id: git::Oid,
|
||||
review_id: cob::patch::ReviewId,
|
||||
) -> Result<Option<models::patch::Review>, Error> {
|
||||
let profile = self.profile();
|
||||
let repo = profile.storage.repository(rid)?;
|
||||
let patches = profile.patches(&repo)?;
|
||||
let review = patches.get(&id.into())?.and_then(|patch| {
|
||||
let aliases = &profile.aliases();
|
||||
|
||||
patch
|
||||
.reviews_of(revision_id.into())
|
||||
.find(|(id, _)| *id == &review_id)
|
||||
.map(|(_, review)| models::patch::Review::new(review.clone(), aliases))
|
||||
});
|
||||
|
||||
Ok::<_, Error>(review)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PatchesMut: Profile {
|
||||
|
||||
@@ -7,9 +7,3 @@ export function fileDiffPath(file: FileDiff): string {
|
||||
? file.newPath
|
||||
: file.path;
|
||||
}
|
||||
|
||||
// A default filename for saving a single file's diff to disk.
|
||||
export function fileDiffName(file: FileDiff): string {
|
||||
const base = fileDiffPath(file).split("/").pop() || "file";
|
||||
return `${base}.diff`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user