mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-20 22:00:43 +08:00
Deduplicate the diff/cob Stats type
This commit is contained in:
@@ -41,7 +41,7 @@ pub async fn diff_stats(
|
||||
rid: RepoId,
|
||||
base: git::Oid,
|
||||
head: git::Oid,
|
||||
) -> Result<types::cobs::Stats, Error> {
|
||||
) -> Result<types::diff::Stats, Error> {
|
||||
ctx.diff_stats(rid, base, head)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type Stats = {
|
||||
files_changed: number;
|
||||
insertions: number;
|
||||
deletions: number;
|
||||
};
|
||||
@@ -96,25 +96,6 @@ pub struct PaginatedQuery<T> {
|
||||
pub content: T,
|
||||
}
|
||||
|
||||
#[derive(TS, Serialize)]
|
||||
#[ts(export)]
|
||||
#[ts(export_to = "cob/")]
|
||||
pub struct Stats {
|
||||
pub files_changed: usize,
|
||||
pub insertions: usize,
|
||||
pub deletions: usize,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
pub fn new(stats: &radicle_surf::diff::Stats) -> Self {
|
||||
Self {
|
||||
files_changed: stats.files_changed,
|
||||
insertions: stats.insertions,
|
||||
deletions: stats.deletions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod query {
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
@@ -14,6 +14,16 @@ pub struct Diff {
|
||||
pub stats: Stats,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
pub fn new(stats: &radicle_surf::diff::Stats) -> Self {
|
||||
Self {
|
||||
files_changed: stats.files_changed,
|
||||
insertions: stats.insertions,
|
||||
deletions: stats.deletions,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<surf::diff::Diff> for Diff {
|
||||
fn from(value: surf::diff::Diff) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -10,6 +10,7 @@ use radicle::storage::{ReadRepository, ReadStorage, RepositoryInfo};
|
||||
use radicle::{git, identity};
|
||||
|
||||
use crate::cobs;
|
||||
use crate::diff;
|
||||
use crate::diff::Diff;
|
||||
use crate::error::Error;
|
||||
use crate::repo::{self, RepoCount};
|
||||
@@ -122,7 +123,7 @@ pub trait Repo: Profile {
|
||||
rid: identity::RepoId,
|
||||
base: git::Oid,
|
||||
head: git::Oid,
|
||||
) -> Result<cobs::Stats, Error> {
|
||||
) -> Result<diff::Stats, Error> {
|
||||
let profile = self.profile();
|
||||
let repo = radicle_surf::Repository::open(storage::git::paths::repository(
|
||||
&profile.storage,
|
||||
@@ -133,7 +134,7 @@ pub trait Repo: Profile {
|
||||
let diff = repo.diff(base.id, commit.id)?;
|
||||
let stats = diff.stats();
|
||||
|
||||
Ok::<_, Error>(cobs::Stats::new(stats))
|
||||
Ok::<_, Error>(diff::Stats::new(stats))
|
||||
}
|
||||
|
||||
fn repo_info(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { Stats } from "@bindings/cob/Stats";
|
||||
import type { Stats } from "@bindings/diff/Stats";
|
||||
|
||||
interface Props {
|
||||
stats: Stats;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type { Commit } from "@bindings/repo/Commit";
|
||||
import type { Diff } from "@bindings/diff/Diff";
|
||||
import type { DiffOptions } from "@bindings/cob/DiffOptions";
|
||||
import type { Stats } from "@bindings/cob/Stats";
|
||||
import type { Stats } from "@bindings/diff/Stats";
|
||||
|
||||
import * as tauri from "@tauri-apps/api/core";
|
||||
import { cached } from "@app/lib/cached";
|
||||
|
||||
Reference in New Issue
Block a user