From 7ed8a10067d69edc97679e0f42eeb51e646dd893 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 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 file(s) changed, 63 insertion(s)(+), 19 deletion(s)(-) diff --git a/api/tangled/repoblob.go b/api/tangled/repoblob.go --- a/api/tangled/repoblob.go +++ b/api/tangled/repoblob.go @@ -30,7 +30,7 @@ // 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 @@ // ref: The git reference used 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. @@ -54,6 +56,16 @@ // name: Author name Name string `json:"name" cborgen:"name"` // when: Author timestamp 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". diff --git a/api/tangled/repotree.go b/api/tangled/repotree.go --- a/api/tangled/repotree.go +++ b/api/tangled/repotree.go @@ -47,10 +47,6 @@ } // 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 --- a/lexicons/repo/blob.json +++ b/lexicons/repo/blob.json @@ -6,7 +6,11 @@ "main": { "type": "query", "parameters": { "type": "params", - "required": ["repo", "ref", "path"], + "required": [ + "repo", + "ref", + "path" + ], "properties": { "repo": { "type": "string", @@ -31,7 +35,10 @@ "output": { "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", @@ -61,6 +71,11 @@ }, "mimeType": { "type": "string", "description": "MIME type of the file" + }, + "submodule": { + "type": "ref", + "ref": "#submodule", + "description": "Submodule information if path is a submodule" }, "lastCommit": { "type": "ref", @@ -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", @@ -131,6 +154,27 @@ "when": { "type": "string", "format": "datetime", "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 --- 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", @@ -104,14 +104,6 @@ }, "size": { "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", -- tangled.sh