From 58326f2661b7e6e0e3a56b71ec1ca8bc18ce8a67 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 11 Nov 2025 11:23:41 +0000 Subject: [PATCH] lexicons: rework lexicons to add submodule support Change-Id: ouvzmklmvrupnpnyxkwwtznmrpytksmp the blob response will additionally include submodule information if the file is a git-submodule file. Signed-off-by: oppiliappan --- api/tangled/repoblob.go | 14 ++++++++++- api/tangled/repotree.go | 4 --- lexicons/repo/blob.json | 54 +++++++++++++++++++++++++++++++++++++---- lexicons/repo/tree.json | 10 +------- 4 files changed, 63 insertions(+), 19 deletions(-) diff --git a/api/tangled/repoblob.go b/api/tangled/repoblob.go index 50306a4e..1984ea06 100644 --- a/api/tangled/repoblob.go +++ b/api/tangled/repoblob.go @@ -30,7 +30,7 @@ type RepoBlob_LastCommit struct { // RepoBlob_Output is the output of a sh.tangled.repo.blob call. type RepoBlob_Output struct { // content: File content (base64 encoded for binary files) - Content string `json:"content" cborgen:"content"` + Content *string `json:"content,omitempty" cborgen:"content,omitempty"` // encoding: Content encoding Encoding *string `json:"encoding,omitempty" cborgen:"encoding,omitempty"` // isBinary: Whether the file is binary @@ -44,6 +44,8 @@ type RepoBlob_Output struct { Ref string `json:"ref" cborgen:"ref"` // size: File size in bytes Size *int64 `json:"size,omitempty" cborgen:"size,omitempty"` + // submodule: Submodule information if path is a submodule + Submodule *RepoBlob_Submodule `json:"submodule,omitempty" cborgen:"submodule,omitempty"` } // RepoBlob_Signature is a "signature" in the sh.tangled.repo.blob schema. @@ -56,6 +58,16 @@ type RepoBlob_Signature struct { When string `json:"when" cborgen:"when"` } +// RepoBlob_Submodule is a "submodule" in the sh.tangled.repo.blob schema. +type RepoBlob_Submodule struct { + // branch: Branch to track in the submodule + Branch *string `json:"branch,omitempty" cborgen:"branch,omitempty"` + // name: Submodule name + Name string `json:"name" cborgen:"name"` + // url: Submodule repository URL + Url string `json:"url" cborgen:"url"` +} + // RepoBlob calls the XRPC method "sh.tangled.repo.blob". // // path: Path to the file within the repository diff --git a/api/tangled/repotree.go b/api/tangled/repotree.go index b7776815..0b90bfa5 100644 --- a/api/tangled/repotree.go +++ b/api/tangled/repotree.go @@ -47,10 +47,6 @@ type RepoTree_Readme struct { // RepoTree_TreeEntry is a "treeEntry" in the sh.tangled.repo.tree schema. type RepoTree_TreeEntry struct { - // is_file: Whether this entry is a file - Is_file bool `json:"is_file" cborgen:"is_file"` - // is_subtree: Whether this entry is a directory/subtree - Is_subtree bool `json:"is_subtree" cborgen:"is_subtree"` Last_commit *RepoTree_LastCommit `json:"last_commit,omitempty" cborgen:"last_commit,omitempty"` // mode: File mode Mode string `json:"mode" cborgen:"mode"` diff --git a/lexicons/repo/blob.json b/lexicons/repo/blob.json index 10b8e1bf..41a339fa 100644 --- a/lexicons/repo/blob.json +++ b/lexicons/repo/blob.json @@ -6,7 +6,11 @@ "type": "query", "parameters": { "type": "params", - "required": ["repo", "ref", "path"], + "required": [ + "repo", + "ref", + "path" + ], "properties": { "repo": { "type": "string", @@ -31,7 +35,10 @@ "encoding": "application/json", "schema": { "type": "object", - "required": ["ref", "path", "content"], + "required": [ + "ref", + "path" + ], "properties": { "ref": { "type": "string", @@ -48,7 +55,10 @@ "encoding": { "type": "string", "description": "Content encoding", - "enum": ["utf-8", "base64"] + "enum": [ + "utf-8", + "base64" + ] }, "size": { "type": "integer", @@ -62,6 +72,11 @@ "type": "string", "description": "MIME type of the file" }, + "submodule": { + "type": "ref", + "ref": "#submodule", + "description": "Submodule information if path is a submodule" + }, "lastCommit": { "type": "ref", "ref": "#lastCommit" @@ -90,7 +105,11 @@ }, "lastCommit": { "type": "object", - "required": ["hash", "message", "when"], + "required": [ + "hash", + "message", + "when" + ], "properties": { "hash": { "type": "string", @@ -117,7 +136,11 @@ }, "signature": { "type": "object", - "required": ["name", "email", "when"], + "required": [ + "name", + "email", + "when" + ], "properties": { "name": { "type": "string", @@ -133,6 +156,27 @@ "description": "Author timestamp" } } + }, + "submodule": { + "type": "object", + "required": [ + "name", + "url" + ], + "properties": { + "name": { + "type": "string", + "description": "Submodule name" + }, + "url": { + "type": "string", + "description": "Submodule repository URL" + }, + "branch": { + "type": "string", + "description": "Branch to track in the submodule" + } + } } } } diff --git a/lexicons/repo/tree.json b/lexicons/repo/tree.json index 4d5101d0..57564dc2 100644 --- a/lexicons/repo/tree.json +++ b/lexicons/repo/tree.json @@ -91,7 +91,7 @@ }, "treeEntry": { "type": "object", - "required": ["name", "mode", "size", "is_file", "is_subtree"], + "required": ["name", "mode", "size"], "properties": { "name": { "type": "string", @@ -105,14 +105,6 @@ "type": "integer", "description": "File size in bytes" }, - "is_file": { - "type": "boolean", - "description": "Whether this entry is a file" - }, - "is_subtree": { - "type": "boolean", - "description": "Whether this entry is a directory/subtree" - }, "last_commit": { "type": "ref", "ref": "#lastCommit" -- 2.43.0