From d68206ba35d8adb2bec3c25a601fbdc2dd7c65a7 Mon Sep 17 00:00:00 2001 From: dawn Date: Thu, 3 Sep 2026 19:15:20 +0900 Subject: [PATCH] lexicons,api,web: add git.temp2.getBlame schema and bindings The mirror answers blame under its own nsid rather than the knot's sh.tangled.repo.blame: it takes a repo did instead of an at-uri and hands back full commit messages, like every other git.temp2 read. Regenerating also emitted the target commit field that git.mergeCommit has required all along; the checked-in Go binding had gone stale and no Go caller builds that struct. Signed-off-by: dawn --- api/tangled/gitmergeCommit.go | 2 + api/tangled/temp2getBlame.go | 62 ++++++++ lexicons/git/temp2/getBlame.json | 136 ++++++++++++++++++ web/src/lib/api/lexicons/index.ts | 1 + .../types/sh/tangled/git/temp2/getBlame.ts | 102 +++++++++++++ 5 files changed, 303 insertions(+) create mode 100644 api/tangled/temp2getBlame.go create mode 100644 lexicons/git/temp2/getBlame.json create mode 100644 web/src/lib/api/lexicons/types/sh/tangled/git/temp2/getBlame.ts diff --git a/api/tangled/gitmergeCommit.go b/api/tangled/gitmergeCommit.go index e917fe2da..b7067ea22 100644 --- a/api/tangled/gitmergeCommit.go +++ b/api/tangled/gitmergeCommit.go @@ -43,6 +43,8 @@ type GitMergeCommit_Source struct { type GitMergeCommit_Target struct { // branch: Target branch to merge into Branch string `json:"branch" cborgen:"branch"` + // commit: Head commit ID of target branch + Commit string `json:"commit" cborgen:"commit"` // repo: DID of target git repository Repo string `json:"repo" cborgen:"repo"` } diff --git a/api/tangled/temp2getBlame.go b/api/tangled/temp2getBlame.go new file mode 100644 index 000000000..043cd6ca6 --- /dev/null +++ b/api/tangled/temp2getBlame.go @@ -0,0 +1,62 @@ +// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. + +package tangled + +// schema: sh.tangled.git.temp2.getBlame + +import ( + "context" + + "github.com/bluesky-social/indigo/lex/util" +) + +const ( + GitTemp2GetBlameNSID = "sh.tangled.git.temp2.getBlame" +) + +// GitTemp2GetBlame_Commit is a "commit" in the sh.tangled.git.temp2.getBlame schema. +type GitTemp2GetBlame_Commit struct { + Author *GitDefs_Signature `json:"author" cborgen:"author"` + // message: Full commit message + Message string `json:"message" cborgen:"message"` + Oid string `json:"oid" cborgen:"oid"` +} + +// GitTemp2GetBlame_Output is the output of a sh.tangled.git.temp2.getBlame call. +type GitTemp2GetBlame_Output struct { + // commit: The resolved git commit object id + Commit string `json:"commit" cborgen:"commit"` + // commits: Unique commits referenced by blame runs + Commits []*GitTemp2GetBlame_Commit `json:"commits" cborgen:"commits"` + // runs: Complete, gap-free one-based line ranges sorted by start + Runs []*GitTemp2GetBlame_Run `json:"runs" cborgen:"runs"` +} + +// GitTemp2GetBlame_Run is a "run" in the sh.tangled.git.temp2.getBlame schema. +type GitTemp2GetBlame_Run struct { + // commit: oid of a commit in the output commits array + Commit string `json:"commit" cborgen:"commit"` + // count: Number of consecutive lines in this run + Count int64 `json:"count" cborgen:"count"` + // start: First one-based line in this run + Start int64 `json:"start" cborgen:"start"` +} + +// GitTemp2GetBlame calls the XRPC method "sh.tangled.git.temp2.getBlame". +// +// path: Path to the file within the repository +// ref: Revspec to blame at: a branch, tag, or commit sha +// repo: DID of the repository +func GitTemp2GetBlame(ctx context.Context, c util.LexClient, path string, ref string, repo string) (*GitTemp2GetBlame_Output, error) { + var out GitTemp2GetBlame_Output + + params := map[string]interface{}{} + params["path"] = path + params["ref"] = ref + params["repo"] = repo + if err := c.LexDo(ctx, util.Query, "", "sh.tangled.git.temp2.getBlame", params, nil, &out); err != nil { + return nil, err + } + + return &out, nil +} diff --git a/lexicons/git/temp2/getBlame.json b/lexicons/git/temp2/getBlame.json new file mode 100644 index 000000000..f28d676d8 --- /dev/null +++ b/lexicons/git/temp2/getBlame.json @@ -0,0 +1,136 @@ +{ + "lexicon": 1, + "id": "sh.tangled.git.temp2.getBlame", + "defs": { + "main": { + "type": "query", + "parameters": { + "type": "params", + "required": [ + "repo", + "ref", + "path" + ], + "properties": { + "repo": { + "type": "string", + "format": "did", + "description": "DID of the repository" + }, + "ref": { + "type": "string", + "description": "Revspec to blame at: a branch, tag, or commit sha" + }, + "path": { + "type": "string", + "description": "Path to the file within the repository" + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": [ + "commit", + "commits", + "runs" + ], + "properties": { + "commit": { + "type": "string", + "description": "The resolved git commit object id" + }, + "commits": { + "type": "array", + "description": "Unique commits referenced by blame runs", + "items": { + "type": "ref", + "ref": "#commit" + } + }, + "runs": { + "type": "array", + "description": "Complete, gap-free one-based line ranges sorted by start", + "items": { + "type": "ref", + "ref": "#run" + } + } + } + } + }, + "errors": [ + { + "name": "RepoNotFound", + "description": "Repository not found or access denied" + }, + { + "name": "RefNotFound", + "description": "Git reference not found" + }, + { + "name": "FileNotFound", + "description": "File not found at the specified path" + }, + { + "name": "BlameTooLarge", + "description": "Blame exceeds file byte, line, or run limits" + }, + { + "name": "BlameTimeout", + "description": "Blame exceeded its computation time budget" + }, + { + "name": "InvalidRequest", + "description": "Invalid request parameters" + } + ] + }, + "commit": { + "type": "object", + "required": [ + "oid", + "message", + "author" + ], + "properties": { + "oid": { + "type": "string" + }, + "message": { + "type": "string", + "description": "Full commit message" + }, + "author": { + "type": "ref", + "ref": "sh.tangled.git.defs#signature" + } + } + }, + "run": { + "type": "object", + "required": [ + "start", + "count", + "commit" + ], + "properties": { + "start": { + "type": "integer", + "minimum": 1, + "description": "First one-based line in this run" + }, + "count": { + "type": "integer", + "minimum": 1, + "description": "Number of consecutive lines in this run" + }, + "commit": { + "type": "string", + "description": "oid of a commit in the output commits array" + } + } + } + } +} diff --git a/web/src/lib/api/lexicons/index.ts b/web/src/lib/api/lexicons/index.ts index a0349c6e6..868a95e49 100644 --- a/web/src/lib/api/lexicons/index.ts +++ b/web/src/lib/api/lexicons/index.ts @@ -104,6 +104,7 @@ export * as ShTangledGitTempListBranches from "./types/sh/tangled/git/temp/listB export * as ShTangledGitTempListCommits from "./types/sh/tangled/git/temp/listCommits.js"; export * as ShTangledGitTempListLanguages from "./types/sh/tangled/git/temp/listLanguages.js"; export * as ShTangledGitTempListTags from "./types/sh/tangled/git/temp/listTags.js"; +export * as ShTangledGitTemp2GetBlame from "./types/sh/tangled/git/temp2/getBlame.js"; export * as ShTangledGitTemp2GetDiff from "./types/sh/tangled/git/temp2/getDiff.js"; export * as ShTangledGitTemp2GetInterdiff from "./types/sh/tangled/git/temp2/getInterdiff.js"; export * as ShTangledGitTemp2ListCommits from "./types/sh/tangled/git/temp2/listCommits.js"; diff --git a/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/getBlame.ts b/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/getBlame.ts new file mode 100644 index 000000000..70d0b38c2 --- /dev/null +++ b/web/src/lib/api/lexicons/types/sh/tangled/git/temp2/getBlame.ts @@ -0,0 +1,102 @@ +import type {} from "@atcute/lexicons"; +import * as v from "@atcute/lexicons/validations"; +import type {} from "@atcute/lexicons/ambient"; +import * as ShTangledGitDefs from "../defs.js"; + +const _commitSchema = /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literal("sh.tangled.git.temp2.getBlame#commit"), + ), + get author() { + return ShTangledGitDefs.signatureSchema; + }, + /** + * Full commit message + */ + message: /*#__PURE__*/ v.string(), + oid: /*#__PURE__*/ v.string(), +}); +const _mainSchema = /*#__PURE__*/ v.query("sh.tangled.git.temp2.getBlame", { + params: /*#__PURE__*/ v.object({ + /** + * Path to the file within the repository + */ + path: /*#__PURE__*/ v.string(), + /** + * Revspec to blame at: a branch, tag, or commit sha + */ + ref: /*#__PURE__*/ v.string(), + /** + * DID of the repository + */ + repo: /*#__PURE__*/ v.didString(), + }), + output: { + type: "lex", + schema: /*#__PURE__*/ v.object({ + /** + * The resolved git commit object id + */ + commit: /*#__PURE__*/ v.string(), + /** + * Unique commits referenced by blame runs + */ + get commits() { + return /*#__PURE__*/ v.array(commitSchema); + }, + /** + * Complete, gap-free one-based line ranges sorted by start + */ + get runs() { + return /*#__PURE__*/ v.array(runSchema); + }, + }), + }, +}); +const _runSchema = /*#__PURE__*/ v.object({ + $type: /*#__PURE__*/ v.optional( + /*#__PURE__*/ v.literal("sh.tangled.git.temp2.getBlame#run"), + ), + /** + * oid of a commit in the output commits array + */ + commit: /*#__PURE__*/ v.string(), + /** + * Number of consecutive lines in this run + * @minimum 1 + */ + count: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.integer(), [ + /*#__PURE__*/ v.integerRange(1), + ]), + /** + * First one-based line in this run + * @minimum 1 + */ + start: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.integer(), [ + /*#__PURE__*/ v.integerRange(1), + ]), +}); + +type commit$schematype = typeof _commitSchema; +type main$schematype = typeof _mainSchema; +type run$schematype = typeof _runSchema; + +export interface commitSchema extends commit$schematype {} +export interface mainSchema extends main$schematype {} +export interface runSchema extends run$schematype {} + +export const commitSchema = _commitSchema as commitSchema; +export const mainSchema = _mainSchema as mainSchema; +export const runSchema = _runSchema as runSchema; + +export interface Commit extends v.InferInput {} +export interface Run extends v.InferInput {} + +export interface $params extends v.InferInput {} +export interface $output extends v.InferXRPCBodyInput {} + +declare module "@atcute/lexicons/ambient" { + interface XRPCQueries { + "sh.tangled.git.temp2.getBlame": mainSchema; + } +} -- 2.51.2