diff --git a/web/src/lib/api/gitmirror.ts b/web/src/lib/api/gitmirror.ts index cbecb7531..c0812d005 100644 --- a/web/src/lib/api/gitmirror.ts +++ b/web/src/lib/api/gitmirror.ts @@ -62,7 +62,7 @@ export const listLog = async ( ): Promise => { const page = await listCommits( ctx, - { repo, ranges: [`${range.base}..${range.head}`], limit: LOG_LIMIT }, + { repo, ranges: [`${range.base}..${range.head}`], limit: LOG_LIMIT, includeStats: true }, init ); return page.commits.map(toMirrorCommitSummary); @@ -140,7 +140,12 @@ export const toMirrorCommitSummary = (commit: MirrorCommit): CommitSummary => { when: commit.committer.when ?? commit.author.when, // the pull page links a commit row as `firstParent..commit` parent: commit.parents[0], - changeId: mirrorChangeId(commit) + changeId: mirrorChangeId(commit), + stat: commit.stat && { + insertions: commit.stat.insertions, + deletions: commit.stat.deletions, + files_changed: commit.stat.filesChanged + } }; }; diff --git a/web/src/lib/api/lexicons/types/sh/tangled/git/defs.ts b/web/src/lib/api/lexicons/types/sh/tangled/git/defs.ts index 41a063fa8..ec59747ce 100644 --- a/web/src/lib/api/lexicons/types/sh/tangled/git/defs.ts +++ b/web/src/lib/api/lexicons/types/sh/tangled/git/defs.ts @@ -50,6 +50,23 @@ const _diffSrcSchema = /*#__PURE__*/ v.object({ */ size: /*#__PURE__*/ v.integer(), }); +const _diffStatSchema = /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literal("sh.tangled.git.defs#diffStat"), + ), + /** + * @minimum 0 + */ + deletions: /*#__PURE__*/ v.integer(), + /** + * @minimum 0 + */ + filesChanged: /*#__PURE__*/ v.integer(), + /** + * @minimum 0 + */ + insertions: /*#__PURE__*/ v.integer(), +}); const _fileDiffSchema = /*#__PURE__*/ v.object({ $type: /*#__PURE__*/ v.optional( /*#__PURE__*/ v.literal("sh.tangled.git.defs#fileDiff"), @@ -105,6 +122,7 @@ const _signatureSchema = /*#__PURE__*/ v.object({ type byteChanges$schematype = typeof _byteChangesSchema; type diffHunk$schematype = typeof _diffHunkSchema; type diffSrc$schematype = typeof _diffSrcSchema; +type diffStat$schematype = typeof _diffStatSchema; type fileDiff$schematype = typeof _fileDiffSchema; type linePair$schematype = typeof _linePairSchema; type signature$schematype = typeof _signatureSchema; @@ -112,6 +130,7 @@ type signature$schematype = typeof _signatureSchema; export interface byteChangesSchema extends byteChanges$schematype {} export interface diffHunkSchema extends diffHunk$schematype {} export interface diffSrcSchema extends diffSrc$schematype {} +export interface diffStatSchema extends diffStat$schematype {} export interface fileDiffSchema extends fileDiff$schematype {} export interface linePairSchema extends linePair$schematype {} export interface signatureSchema extends signature$schematype {} @@ -119,6 +138,7 @@ export interface signatureSchema extends signature$schematype {} export const byteChangesSchema = _byteChangesSchema as byteChangesSchema; export const diffHunkSchema = _diffHunkSchema as diffHunkSchema; export const diffSrcSchema = _diffSrcSchema as diffSrcSchema; +export const diffStatSchema = _diffStatSchema as diffStatSchema; export const fileDiffSchema = _fileDiffSchema as fileDiffSchema; export const linePairSchema = _linePairSchema as linePairSchema; export const signatureSchema = _signatureSchema as signatureSchema; @@ -126,6 +146,7 @@ export const signatureSchema = _signatureSchema as signatureSchema; export interface ByteChanges extends v.InferInput {} export interface DiffHunk extends v.InferInput {} export interface DiffSrc extends v.InferInput {} +export interface DiffStat extends v.InferInput {} export interface FileDiff extends v.InferInput {} export interface LinePair extends v.InferInput {} export interface Signature extends v.InferInput {} diff --git a/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/listCommits.ts b/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/listCommits.ts index 459aa4b1c..cc5b120d9 100644 --- a/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/listCommits.ts +++ b/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/listCommits.ts @@ -19,6 +19,9 @@ const _commitSchema = /*#__PURE__*/ v.object({ message: /*#__PURE__*/ v.string(), oid: /*#__PURE__*/ v.string(), parents: /*#__PURE__*/ v.array(/*#__PURE__*/ v.string()), + get stat() { + return /*#__PURE__*/ v.optional(ShTangledGitDefs.diffStatSchema); + }, tree: /*#__PURE__*/ v.string(), }); const _headerSchema = /*#__PURE__*/ v.object({ @@ -36,6 +39,11 @@ const _mainSchema = /*#__PURE__*/ v.query("sh.tangled.git.temp2.listCommits", { */ allRefs: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), false), before: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.datetimeString()), + /** + * Diff each commit against its first parent and include a line stat + * @default false + */ + includeStats: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.boolean(), false), /** * Maximum number of commits to return * @minimum 1 diff --git a/web/src/lib/api/repo.ts b/web/src/lib/api/repo.ts index 83cd37908..0f3c6136b 100644 --- a/web/src/lib/api/repo.ts +++ b/web/src/lib/api/repo.ts @@ -1,6 +1,6 @@ import { isDid } from "@atcute/lexicons/syntax"; import { ClientResponseError, type BobbinContext, type XrpcRequestInit } from "$lib/api/client"; -import type { NiceCommit } from "$lib/api/diff"; +import type { LineStat, NiceCommit } from "$lib/api/diff"; import { REPO_OWNER_DOCS } from "$lib/api/descriptors"; import { authorOf, enrich, target } from "$lib/api/enrich"; import { getRepoByName, type RecordList, type RecordView, type RepoRecord } from "$lib/api/records"; @@ -203,6 +203,7 @@ export interface CommitSummary { parent?: string; // pinned comments referencing this commit commentCount?: number; + stat?: LineStat; } export const didFromSignature = (email: string): string | undefined => diff --git a/web/src/lib/components/repo/pulls/PullCommitList.stories.svelte b/web/src/lib/components/repo/pulls/PullCommitList.stories.svelte index 1e2377c71..a701f60eb 100644 --- a/web/src/lib/components/repo/pulls/PullCommitList.stories.svelte +++ b/web/src/lib/components/repo/pulls/PullCommitList.stories.svelte @@ -17,7 +17,8 @@ authorName: "oppi", authorEmail: "oppi@example.test", when: "2026-08-20T15:00:00Z", - changeId: "zsuskuln" + changeId: "zsuskuln", + stat: { insertions: 4, deletions: 9 } }, { hash: "c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2", @@ -27,7 +28,8 @@ authorName: "oppi", authorEmail: "oppi@example.test", when: "2026-08-20T14:30:00Z", - changeId: "rlvkpxrz" + changeId: "rlvkpxrz", + stat: { insertions: 12, deletions: 3 } }, { hash: "b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1", @@ -37,7 +39,8 @@ authorName: "anirudh", authorEmail: "anirudh@example.test", when: "2026-08-19T11:00:00Z", - changeId: "kkmtprmw" + changeId: "kkmtprmw", + stat: { insertions: 148, deletions: 0 } }, { // a repo without jj change ids has no stable identity to narrow to diff --git a/web/src/lib/components/repo/pulls/PullCommitRow.svelte b/web/src/lib/components/repo/pulls/PullCommitRow.svelte index 8c6dac547..31b6b5eea 100644 --- a/web/src/lib/components/repo/pulls/PullCommitRow.svelte +++ b/web/src/lib/components/repo/pulls/PullCommitRow.svelte @@ -1,6 +1,7 @@